Monday 29 October 2012

Find out what TCP/UDP Ports are being used and by what program

Find out what TCP/UDP Ports are being used and by what program

I have been asked a few times in the past why certain programs will not work, mainly web-servers running on port 80, the sites wont start due to another application using the port.

There is a simple command you can run to cross check with task manager what ports are being used, you may already be familiar with netstat it is used for many things within the OS to check what your computer is doing on the internet, simply doing a "netstat -n -n -o" in a command prompt will give you a lot of results, showing all the inbound and outbound connections and what ports are being used.

If you specifically want to find a certain port you can use the pipe command after and the word findstr so the command would look like this netstat -a -n -o | findstr :80 this would find all the connections that are on port 80 in and out.

To drill down even further you need to put in 0.0:80 at the end so the command will look like this netstat -a -n -o | findstr 0.0:80 this will then give you a very small number of results specifically for the local host and anything with 80 in there as you can see from my picture it has both port 80 and port 8080.

 Now you will notice at the end of the results are some numbers these are whats known as the PID and we can cross check these in Windows Task Manager, then by going to the Services tab you will see there is a column with PID sort by numerical order and find the matching number to give you the service which is using the port, and if you need to stop the service.

No comments:

Post a Comment