Web Server Failed To Start. Port 8080 Was Already In Use. Spring Boot Microservice

When you see the error message "Web server failed to start. Port 8080 was already in use" in a Spring Boot microservice, it means that another application or process is already using port 8080 on your machine.

To resolve this issue, you can try the following:

  1. Find and kill the process using port 8080: In a terminal or command prompt, run the following command to find the process ID (PID) using port 8080:

    • For Windows: netstat -ano | findstr :8080
    • For Unix/Linux/Mac: lsof -i :8080

    Once you have identified the PID, you can kill the process using the following command:

    • For Windows: taskkill /F /PID <PID>
    • For Unix/Linux/Mac: kill <PID>

    After killing the process, try running your Spring Boot microservice again.

  2. Find and change the configured port: If you cannot kill the process using port 8080 or if you need to run multiple services on the same port, you can change the port that your Spring Boot microservice listens on.
    Open the application.properties (or application.yml) file in your project’s src/main/resources directory, and add the following line:

    server.port=8081

    This will change the port to 8081. You can choose any available port. Save the file and run your microservice again.

  3. Disable the service using port 8080: If the process using port 8080 is a service that you don’t need, you can disable it to free up the port. How to disable a service depends on your operating system and setup, so you may need to consult the relevant documentation.

Remember to restart your microservice after making any changes.

About the Author Rex

I'm a passionate tech blogger with an insatiable love for programming! From my early days tinkering with code, I've delved into web dev, mobile apps, and AI. Sharing insights and tutorials with the world is my joy, connecting me to a global community of like-minded tech enthusiasts. Python holds a special place in my heart, but I embrace all challenges. Constantly learning, I attend tech conferences, contribute to open-source projects, and engage in code review sessions. My ultimate goal is to inspire the next generation of developers and contribute positively to the ever-evolving tech landscape. Let's code together!