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: 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                LISTENING       496
TCP                LISTENING       4
TCP               LISTENING       1128
TCP               LISTENING       2524
TCP               LISTENING       1708
TCP               LISTENING       424
TCP               LISTENING       2524
TCP               LISTENING       1292
TCP               LISTENING       2904
TCP               LISTENING       1456
TCP               LISTENING       2904
TCP               LISTENING       2904
TCP              LISTENING       1864
TCP              LISTENING       704
TCP              LISTENING       2524
TCP              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 *