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

The spring boot Web server failed to start. Port 8080 was already in use. error occurs because port 8080 is already configured with another application, or port 8080 has not been released yet. The spring boot application is trying to configure port 8080 to start a web server. Since the port can not be used, this error is thrown. The action is Identify and stop the process that’s listening on port 8080 or configure this application to listen on another port.

The Spring boot application uses tomcat as a web server. The default tomcat port is 8080. If any application listens to port 8080 and if you start the spring boot application, this exception is thrown as tomcat can not use port 8080.



Exception

Description:
 Web server failed to start. Port 8080 was already in use.
 Action:
 Identify and stop the process that's listening on port 8080 or configure this application to listen on another port.


Root Cause

Tomcat is running on port 8080. Spring boot application uses tomcat as the default web server. The port 8080 is currently being used by the application and tomcat is trying to listen to port 8080. A different application may be used for port 8080. Or the current application is already running. You ‘re trying to get started again.



Solution 1

You’ve already started and running the spring boot application. Now you’re trying to run the spring boot application again. Stop all the instance or restart your IDE.

You may be running an instance on a terminal or command line, or run as a service. Now you’re trying to get your IDE started again. Check all the applications that can use port 8080 and make sure the application is not started.



Solution 2

Some external applications already use port 8080. Check the running application in the task manager, stop the application that listen to port 8080.

The running application can be identified by the process commands. Identify the process that uses port 8080. Stop the application so that port 8080 is released to the other application to be used. Run the command below in linux to find the application that uses port 8080, and then kill the process if you want to stop it.

ps -ef | grep 8080

kill -9 <process id>


Solution 3

Some of the valid applications are running the default port. The application that may be used for other purposes can not be stopped. The other option is to change the default listening port in the application.properties and start the spring boot application again.

application.properties

server.port=80

How to create simple Spring Boot Application with Main method



Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *