Problem Statement
Have you bumped into this error before when trying to start the Tomcat server?
java.net.BindException: Address already in use – Tomcat Error
Caused by: org.apache.catalina.LifecycleException: service.getName(): “Tomcat”; Protocol handler start failed
Caused by: java.net.BindException: Address already in use
***************************
APPLICATION FAILED TO START
***************************Description:
The Tomcat connector configured to listen on port 8080 failed to start. The port may already be in use or the connector may be misconfigured.
Action:
Verify the connector’s configuration, identify and stop any process that’s listening on port 8080, or configure this application to listen on another port.
Resolution
The error message states that you have another process which is already serving the port 8080, and as a result your application server is not able to bind to that specific port.
Needless to say, only 1 process can be bound to a given port at any point of time. You will bump into this error, if you are starting tomcat when the earlier instance of tomcat is already running and attached to 8080 port.
To resolve this issue, you have 2 options —
Kill the previous instance —
Find the process number that is listening at the given port —
$ lsof -i TCP:8080
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 9270 Samir 39u IPv6 0x737a9d99c9a999a9 0t0 TCP *:http-alt (LISTEN)
Kill the process running at the given port —
$ kill 9270
Run the application on a different port —
You can modify the port number on which your application is running in the application.yml file —
server:
port: ${service.port:8092}
Do let me know in comments below if this did not resolve your issue, and I will be happy to assist.
Categories: Java
Leave a Reply