Finding what process is using a port in Windows

I had an issue with one of my Tomcat servers unable to stay running. The logs were saying that port 8005 was already bound to another service. Tomcat uses this port number as a default to listen for Shutdown requests. The service that was using the port was a system process, and seeing that it was a customer’s server, it was not an option to shut down the system process. Here are a couple ways to see what service was using the port number.

The easiest way is to open the “Resource Monitor” app and go to the Network tab and expand the “Listening Ports” section. Then just needed to scroll through the list and look to see which process was using port 8005. On my default Tomcat test servers, the result will show tomcat8.exe which is what I would want to see. The customer did not share with me the result of using the Resource Monitor, as they choose instead to use the secondary approach described next.

A second way to see the list of processes and the port numbers is to use the Command Line (be sure to open ‘As Administrator’). First we need to see which process ID is using the network connection at port 8005.

netstat -ano | findstr 8005

We use the netstat command with the options -a -n and -o to see a nice list of all of the port connections and the PID for the service using the connection in the far right column. My test result yielded the result ‘4676’ (your result will likely be very different)

Next we will use the result and plug it into a tasklist call to see what process the PID belongs to.

tasklist | findstr 4676

Of course, replace the number ‘4676’ with the appropriate PID result you found. In the case of my customer, their result was the number ‘4’. This would be a system process. I am unsure at this time what process they are running on their virtual server that is using that port, so we are opting to switch the port number Tomcat is using to listen for shutdown requests. Hope to provide a link here later for my article on that change.

Add a Comment

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