How to Address Already in Use JVM_Bind Error in Java

Sheeraz Gul Feb 02, 2024
How to Address Already in Use JVM_Bind Error in Java

This tutorial demonstrates Java’s address already in use jvm_bind error.

the Address already in use: JVM_Bind Error in Java

The Address already in use: JVM_Bind mostly occurs when we work on web applications. This error is common when using services like Tomcat, Struts, JBoss etc.

The error occurs when we try to bind with a port on which some other application is already listening. To solve this issue, either we have to change the port for the current application or kill the other application running on the same port.

Here is the solution for both scenarios.

Change the Web Server to Run on Another Port

Changing the web server port is an easy task in most scenarios. For example, if you are using Tomcat, follow the process below to change the web server port.

  1. Find the file server.xml, usually in the directory C:/apache-tomcat-7.0.11/conf/server.xml.

  2. The file server.xml will be a code snippet, as shown below.

    <Connector port="8080" protocol="HTTP/1.1"
    			   connectionTimeout="20000"
    			   redirectPort="8443" />
    
  1. Now, change the connector port number to any other port number and save it.
  2. Now, the web server will run on the port number you have given. The error Address already in use: JVM_Bind is solved.

Kill the Previous Service

We can also kill the previous application running on the port to run our application on that port. To do that, we have to find the process in which the service is running and then kill that service.

Here is the process to find and kill the services on Windows and Linux platforms.

For Windows:

  1. First, find the process using your port number. Use the following command.

    netstat -ano | find "8080"
    
  2. The command above will find the process running on the port 8080. Now, for example, the process found is 1234.

  3. Kill the process 1234 by using the following command.

    taskkill /F /PID 1234
    
  1. The taskkill command will kill the process with process id 1234.
  2. Now, we can run our application on the port 8080 without the Address already in use: JVM_Bind error.

For Linux:

  1. Similarly, the netstat command is also used in Linux to find a service or process.

  2. The netstat is used to show the status of the network, and the grep command is used to find the process running on a port. See the command below.

    netstat -an | grep "8080"
    
  3. The command above will find the process running on the port 8080. Now, for example, the process found is 1234.

  4. Use the kill command to kill the 1234 process.

    kill - 1234
    
  5. The Address already in use: JVM_Bind error will be solved after running these commands in Linux.

Author: Sheeraz Gul
Sheeraz Gul avatar Sheeraz Gul avatar

Sheeraz is a Doctorate fellow in Computer Science at Northwestern Polytechnical University, Xian, China. He has 7 years of Software Development experience in AI, Web, Database, and Desktop technologies. He writes tutorials in Java, PHP, Python, GoLang, R, etc., to help beginners learn the field of Computer Science.

LinkedIn Facebook

Related Article - Java Error