networking - How can you find out which process is listening on a TCP or UDP port on Windows?

ID : 217

viewed : 187

Tags : windowsnetworkingportwindows





Top 5 Answer for networking - How can you find out which process is listening on a TCP or UDP port on Windows?

vote vote

92

New answer, powershell

TCP

Get-Process -Id (Get-NetTCPConnection -LocalPort YourPortNumberHere).OwningProcess 

UDP

Get-Process -Id (Get-NetUDPEndpoint -LocalPort YourPortNumberHere).OwningProcess 

Old answer, cmd

 C:\> netstat -a -b 

(Add -n to stop it trying to resolve hostnames, which will make it a lot faster.)

Note Dane's recommendation for TCPView. It looks very useful!

-a Displays all connections and listening ports.

-b Displays the executable involved in creating each connection or listening port. In some cases well-known executables host multiple independent components, and in these cases the sequence of components involved in creating the connection or listening port is displayed. In this case the executable name is in [] at the bottom, on top is the component it called, and so forth until TCP/IP was reached. Note that this option can be time-consuming and will fail unless you have sufficient permissions.

-n Displays addresses and port numbers in numerical form.

-o Displays the owning process ID associated with each connection.

vote vote

85

There's a native GUI for Windows:

  • Start menu → All ProgramsAccessoriesSystem ToolsResource Monitor

  • or run resmon.exe,

  • or from TaskManagerPerformance tab.

Enter image description here

vote vote

76

For Windows:

netstat -aon | find /i "listening" 
vote vote

60

Use TCPView if you want a GUI for this. It's the old Sysinternals application that Microsoft bought out.

vote vote

52

The -b switch mentioned in most answers requires you to have administrative privileges on the machine. You don't really need elevated rights to get the process name!

Find the pid of the process running in the port number (e.g., 8080)

netstat -ano | findStr "8080" 

Find the process name by pid

tasklist /fi "pid eq 2216" 

find process by TCP/IP port

Top 3 video Explaining networking - How can you find out which process is listening on a TCP or UDP port on Windows?







Related QUESTION?