Command line for looking at specific port

Is there a way to examine the status of a specific port from the Windows command line? I know I can use netstat to examine all ports but netstat is slow and looking at a specific port probably isn't.


Solution 1:

Here is the easy solution of port finding...

In cmd:

netstat -na | find "8080"

In bash:

netstat -na | grep "8080"

In PowerShell:

netstat -na | Select-String "8080"

Solution 2:

You can use the netstat combined with the -np flags and a pipe to the find or findstr commands.

Basic Usage is as such:

netstat -np <protocol> | find "port #"

So for example to check port 80 on TCP, you can do this: netstat -np TCP | find "80" Which ends up giving the following kind of output:

TCP    192.168.0.105:50466    64.34.119.101:80       ESTABLISHED
TCP    192.168.0.105:50496    64.34.119.101:80       ESTABLISHED

As you can see, this only shows the connections on port 80 for the TCP protocol.

Solution 3:

I use:

netstat –aon | find "<port number>"

here o represents process ID. now you can do whatever with the process ID. To terminate the process, for e.g., use:

taskkill /F /pid <process ID>