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.
-
Find the file
server.xml
, usually in the directoryC:/apache-tomcat-7.0.11/conf/server.xml
. -
The file
server.xml
will be a code snippet, as shown below.<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
- Now, change the connector port number to any other port number and save it.
- 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:
-
First, find the process using your port number. Use the following command.
netstat -ano | find "8080"
-
The command above will find the process running on the port
8080
. Now, for example, the process found is1234
. -
Kill the process
1234
by using the following command.taskkill /F /PID 1234
- The
taskkill
command will kill the process with process id1234
. - Now, we can run our application on the port
8080
without theAddress already in use: JVM_Bind
error.
For Linux:
-
Similarly, the
netstat
command is also used in Linux to find a service or process. -
The
netstat
is used to show the status of the network, and thegrep
command is used to find the process running on a port. See the command below.netstat -an | grep "8080"
-
The command above will find the process running on the port
8080
. Now, for example, the process found is1234
. -
Use the
kill
command to kill the1234
process.kill - 1234
-
The
Address already in use: JVM_Bind
error will be solved after running these commands in Linux.
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 FacebookRelated Article - Java Error
- How to Fix the Error: Failed to Create the Java Virtual Machine
- How to Fix the Missing Server JVM Error in Java
- How to Fix the 'No Java Virtual Machine Was Found' Error in Eclipse
- How to Fix Javax.Net.SSL.SSLHandShakeException: Remote Host Closed Connection During Handshake
- How to Fix the Error: Failed to Create the Java Virtual Machine
- How to Fix Java.Lang.VerifyError: Bad Type on Operand Stack