java.net.BindException. Signals that an error occurred while attempting to bind a socket to a local address and port. Typically, the port is in use, or the requested local address could not be assigned.
Address already in use: JVM_Bind. means that some other application is already listening on the port your current application is trying to bind. what you need to do is, either change the port for your current application or better; just find out the already running application and kill it.
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 and 9488
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.
In Mac:
Kill process
Terminal: kill <pid>
Find pid:
Terminal: lsof -i:<port>
From Diego Pino answer
(Windows Only)
To kill a process you first need to find the Process Id (pid)
By running the command :
netstat -ano | findstr :yourPortNumber
You will get your Process Id (PID), Now to kill the same process run this command:
taskkill /pid yourid /f
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With