99

I want to be able to figure out what port a particular program is using. Are there any programs available online or that come with windows that will tell me which processes are using which ports on my computer?

PS - before you downmod this for not being a programming question, I'm looking for the program to test some networking code.

Lightness Races in Orbit
  • 358,771
  • 68
  • 593
  • 989
AlexeyMK
  • 5,957
  • 8
  • 32
  • 41

12 Answers12

149

netstat -b -a lists the ports in use and gives you the executable that's using each one. I believe you need to be in the administrator group to do this, and I don't know what security implications there are on Vista.

I usually add -n as well to make it a little faster, but adding -b can make it quite slow.

Edit: If you need more functionality than netstat provides, vasac suggests that you try TCPView.

Community
  • 1
  • 1
Graeme Perrow
  • 51,937
  • 20
  • 74
  • 119
42

TCPView can do what you asked for.

vasac
  • 550
  • 4
  • 6
  • 1
    Thank you; netstat is more than enough for my needs but if I ever need something more hardcore I'll be sure to use TCPView. Should be added to the accepted answer but alas I don't have the right to Edit yet. – AlexeyMK Sep 19 '08 at 20:47
  • I've been using the Netstat utility that comes with XAMPP. But this standalone utility is much useful. Thanks. – Shiyaz Sep 13 '17 at 12:58
25

On Vista, you do need elevated privileges to use the -b option with netstat. To get around that, you could run "netstat -ano" which will show all open ports along with the associated process id. You could then use tasklist to lookup which process has the corresponding id.

C:\>netstat -ano

Active Connections

  Proto  Local Address          Foreign Address        State           PID
  ...
  TCP    [::]:49335             [::]:0                 LISTENING       1056
  ...

C:\>tasklist /fi "pid eq 1056"

Image Name                     PID Session Name        Session#    Mem Usage
========================= ======== ================ =========== ============
sqlservr.exe                  1056 Services                   0     66,192 K
Jim Olsen
  • 271
  • 2
  • 5
13

You may already have Process Explorer (from Sysinternals, now part of Microsoft) installed. If not, go ahead and install it now -- it's just that cool.

In Process Explorer: locate the process in question, right-click and select the TCP/IP tab. It will even show you, for each socket, a stack trace representing the code that opened that socket.

Adam Mitz
  • 5,922
  • 1
  • 25
  • 28
7

If your prefer a GUI interface CurrPorts is free and works with all versions of windows. Shows ports and what process has them open.

ctcherry
  • 26,534
  • 5
  • 61
  • 70
5

"netstat -natp" is what I always use.

Steve Baker
  • 4,169
  • 1
  • 18
  • 14
4

Windows 8 (and likely 7 + Vista) also provide a view in Resource Monitor. If you select the Network tab, there's a section called 'Listening Ports'. Can sort by port number, and see which process is using it.

Mikezx6r
  • 15,961
  • 7
  • 29
  • 31
3

Windows comes with the netstat utility, which should do exactly what you want.

Adam Rosenfield
  • 360,316
  • 93
  • 484
  • 571
1

At a command line, netstat -a will give you lots o' info.

CodeRot
  • 893
  • 5
  • 12
1

You can use the 'netstat' command for this. There's a description of doing this sort of thing here.

tkerwin
  • 111
  • 3
0

Open Ports Scanner works for me.

Arne Evertsson
  • 18,823
  • 18
  • 64
  • 82
-1

most decent firewall programs should allow you to access this information. I know that Agnitum OutpostPro Firewall does.

Toby Mills
  • 986
  • 2
  • 9
  • 13