Web server failed to start. Port 8080 was already in use. Spring Boot microservice

We Are Going To Discuss About Web server failed to start. Port 8080 was already in use. Spring Boot microservice. So lets Start this Java Article.

Web server failed to start. Port 8080 was already in use. Spring Boot microservice

  1. Web server failed to start. Port 8080 was already in use. Spring Boot microservice

    If on windows and your getting this every time you run the application you need to keep doing:
    > netstat -ano | findstr *<port used>* TCP 0.0.0.0:*<port used>* 0.0.0.0:0 LISTENING *<pid>* TCP [::]:*<port used>* [::]:0 LISTENING *<pid>* > taskkill /F /PID *<pid>* SUCCESS: The process with PID *<pid>* has been terminated.

  2. Web server failed to start. Port 8080 was already in use. Spring Boot microservice

    If on windows and your getting this every time you run the application you need to keep doing:
    > netstat -ano | findstr *<port used>* TCP 0.0.0.0:*<port used>* 0.0.0.0:0 LISTENING *<pid>* TCP [::]:*<port used>* [::]:0 LISTENING *<pid>* > taskkill /F /PID *<pid>* SUCCESS: The process with PID *<pid>* has been terminated.

Solution 1

If on windows and your getting this every time you run the application you need to keep doing:

> netstat -ano | findstr *<port used>*

  TCP    0.0.0.0:*<port used>*  0.0.0.0:0              LISTENING       *<pid>*
  TCP    [::]:*<port used>*     [::]:0                 LISTENING       *<pid>*

> taskkill /F /PID *<pid>*
SUCCESS: The process with PID *<pid>* has been terminated.

If netstat above includes something like this;

TCP    [zzzz:e2ce:44xx:1:axx6:dxxf:xxx:xxxx]:540yy [zzzz:e2ce:44xx:1:axx6:dxxf:xxx:xxxx]:*<port used>* TIME_WAIT 0

Then you can either wait for a little while or reconfigure to use another port.

I suppose we could write some code to randomly generate and check if a port is free when the application runs. Though this will have diminishing returns as they start to get used up. On the other hand could add a resource clean up code that does what we have above once the application stops.

Original Author Of This Content

Solution 2

You can change the default port of your application in application.properties by adding the following line:

server.port = 8090

Original Author Of This Content

Solution 3

If you don’t want the embedded server to start, just set the following property in you application.properties (or .yml):

spring.main.web-application-type=none

If your classpath contains the necessary bits to start a web server, Spring Boot will automatically start it. To disable this behaviour configure the WebApplicationType in your application.properties

Source: https://docs.spring.io/spring-boot/docs/current/reference/html/howto-embedded-web-servers.html


If you application really is a Web application, then you can easily change the port using the server.port property (in your application’s .properties/.yaml file, as a command line argument at startup, etc).

Original Author Of This Content

Solution 4

Some time if you can manually kill the that port problem can solve.

Using CurrPorts software you can view what are the running all ports in your machine and you can kill that port if you want.

You can download CurrPorts from here. (download link is in bottom of the page)

enter image description here

============== OR ==============

Without CurrPorts you can do this using like below method also.

  1. CMD as run as administrator
  2. Enter netstat -a -o -n and hit enter. Now you can see like below. Port can see Local Address column after : sign.

enter image description here

  1. select the process id(not port) that your port running and type taskkill /F /PID <process_id_here> command and hit enter.

enter image description here

Original Author Of This Content

Conclusion

So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.

Also Read,

Siddharth

I am an Information Technology Engineer. I have Completed my MCA And I have 4 Year Plus Experience, I am a web developer with knowledge of multiple back-end platforms Like PHP, Node.js, Python and frontend JavaScript frameworks Like Angular, React, and Vue.

Leave a Comment