Many times we know the port number and want to get the details of the process running on that port on windows. Reasons may be
- to find which program is using the port.
- the process name running on that port.
- to find the process id(PID) of the process using its port so that we can kill the process.
Windows provides netstat
command. This command has different options which can be used to extract port and process related information.
Find process running on given port
Use the below command if you know the port and want to get the PID of process running on it.
netstat -aon | findStr “<port number>”
Example,
netstat -aon | findStr “49691”
returned the following output on my windows machine
Rightmost column is the PID of the process and second column from the left shows the port number.
Above command options can be explained in detail as below.
-a : Displays all ports of the local machine that have been connected by a process.
-o : Displays the PID of the process running on a port. Removing this option will not display the process ID(PID).
-n : Displays the port numbers in numeric format.
Pipe(|) followed by findStr
operator and the port number is used to filter the processes running on that port.
If you simply execute command netstat -aon
, then it will list all the busy ports on the machine.
Another method to list all the above information along with the name of executable responsible for the process is by using command
netstat -a -b -n -o
But for this you should have administrator privileges, that is, the command prompt should be opened with Administrator rights where
-b : Lists the executable which started the process.
Find listening ports
If you want to check which all ports have a process which is Listening for incoming connections or to check open ports, then use the below command.
netstat -aon | find /i “LISTENING”
where find
is a windows command for searching for a value in the string provided to it and /i is its option for case insensitive search.
If you are using /i, then you can also use “listening”, “Listening” etc., values for search.
Resource Monitor
If you do not want to go with the command line option, then you can use a GUI in the form of Resource Monitor on Windows.
With Resource Monitor, you can get information about the process name, its PID, IP address and Port which it is running on.
You can open Resource Monitor from the Performance tab of Task Manager as shown below.
When you click on the highlighted link in the above image, it opens up a new Resource Monitor window as shown below.
As evident from the above image, Resource Manager contains information about process names, their PIDs, port etc.
If you do not want to open Resource Monitor through Task Manager, you can also open it directly running command resmon.exe from Windows command prompt.
Hope this post helped you out. Click the clap below to appreciate.