How to Avoid Java.Net.Bindexception: Address Already in Use

How do I resolve the Address already in use: JVM_Bind error?

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.

How to avoid Address already in use

You will see that your setReuseAddress(true) is being called too late i.e. after the bind throws an exception.

You can create an unbound ServerSocket, make it reusable and then bind it, in three steps.

ServerSocket ss = new ServerSocket();
ss.bind(new InetSocketAddress(12345));

BindException: Address already in use

The following lines of code is trying to create ServerSocket again (in fact, infinite number of times) on the port, 5000 and that is why you are getting the error.

while (true) {
server = new ServerSocket(port);

Do it as follows:

server = new ServerSocket(port);
}catch(IOException i){
while (true) {
try{ Address already in use: JVM_Bind, in spite of no running port

Probably there is a system process listening at that port. If that is the case, you need to change your port in server.xml file.

How to fix the error Caused by: Address already in use: bind in Quarkus?

It seems that besides the normal HTTP port, there is also a default port used during tests. So in order to override the default port used in tests, the following property needs to be overridden:


This will run the rests using port 8888.

BindException: Address already in use after an application is quited

On Windows, to find and kill the process that is listening to a specified port (often 8080)

  1. Open the Command Prompt as Administrator

  2. netstat -anbo | findstr "8080"

Note: must use double quotes

The last field in the response line is the process id (pid).
Stop the process with

  1. taskkill /F /PID pid

Related Topics

Leave a reply