How do I resolve the "java.net.BindException: Address already in use: JVM_Bind" error?
If you know what port the process is running you can type:
lsof -i:<port>
.
For instance, lsof -i:8080
, to list the process (pid) running on port 8080.
Then kill the process with kill <pid>
Yes you have another process bound to the same port.
TCPView (Windows only) from Windows Sysinternals is my favorite app whenever I have a JVM_BIND error. It shows which processes are listening on which port. It also provides a convenient context menu to either kill the process or close the connection that is getting in the way.
In windows
netstat -ano
will list all the protocols, ports and processes listening . Use
taskkill -pid "proces to kill" /f
to kill the process listening to the port. e.g
taskkill -pid 431 /f
In Ubuntu/Unix we can resolve this problem in 2 steps as described below.
-
Type
netstat -plten |grep java
This will give an output similar to:
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 1001 76084 9488/java
Here
8080
is the port number at which the java process is listening and9488
is its process id (pid). -
In order to free the occupied port, we have to kill this process using the
kill
command.kill -9 9488
9488
is the process id from earlier. We use-9
to force stop the process.
Your port should now be free and you can restart the server.