Address in Use Error using Tomcat on Windows XP

Steve Neal Development 2 Comments

Occasionally you might get an error like this when launching Tomcat:

java.net.BindException: Address already in use: JVM_Bind <null>:8080

This can be caused if you already have Tomcat running as it will hold onto a network port for handling HTTP requests. In the above example the port shown is 8080.

However, this error is sometimes apparent even when Tomcat has already been shut down, expecially if you’ve shut it down abruptly. The problem here is that the Tomcat process may not have completely ended and that Windows is holding onto the network port for it.

To resolve this do the following:

  1. find the process ID that has the port reserved,
  2. kill the process, releasing the port.

Step 1 – Find the process thats holding onto the port

Start a command prompt and enter the command:

netstat -ano

The flags for this cause (a)  all connections and ports to be listed, (n) port numbers to be shown numerically, and importantly (o) which causes the process ID to be included in the output. The results of running this should look something like this:

Active Connections

Proto  Local Address          Foreign Address        State           PID
TCP    0.0.0.0:135            0.0.0.0:0              LISTENING       496
TCP    0.0.0.0:445            0.0.0.0:0              LISTENING       4
TCP    0.0.0.0:1776           0.0.0.0:0              LISTENING       1128
TCP    0.0.0.0:2864           0.0.0.0:0              LISTENING       2524
TCP    0.0.0.0:3306           0.0.0.0:0              LISTENING       1708
TCP    0.0.0.0:3389           0.0.0.0:0              LISTENING       424
TCP    0.0.0.0:6942           0.0.0.0:0              LISTENING       2524
TCP    0.0.0.0:8008           0.0.0.0:0              LISTENING       1292
TCP    0.0.0.0:8009           0.0.0.0:0              LISTENING       2904
TCP    0.0.0.0:8012           0.0.0.0:0              LISTENING       1456
TCP    0.0.0.0:8080           0.0.0.0:0              LISTENING       2904
TCP    0.0.0.0:8443           0.0.0.0:0              LISTENING       2904
TCP    0.0.0.0:15000          0.0.0.0:0              LISTENING       1864
TCP    0.0.0.0:33115          0.0.0.0:0              LISTENING       704
TCP    0.0.0.0:63342          0.0.0.0:0              LISTENING       2524
TCP    10.136.38.94:139       0.0.0.0:0              LISTENING       4

In the output, port 8080 (under Local Address, on line 14) can be seen to belong to process ID (PID) 2904.

Step 2 – Kill the process

Press <CTRL><ALT><DEL> and then select Task Manager, then from the Task Manager choose the menus: View | Select Columns. In the dialog that appears check the PID checkbox to display the process ID and then dismiss it by pressing OK.

With the Processes tab selected you should be able to idenify the process with the PID that we found in step 1. In this example the value would be 2904.

Select this process and click End Process. Confirm that you want to kill the process and you should find that once it has been killed off, the network port it was holding has been released.

Comments 2

Leave a Reply

Your email address will not be published. Required fields are marked *