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 spe
For Windows 8 User : Open Command Prompt, type netstat -an | find "your port number" , enter .
If reply comes like LISTENING then the port is in use, else it is free .
For port 80, the command would be : netstat -an | find "80" For port n, the command would be : netstat -an | find "n"
Here, netstat is the instruction to your machine
-a : Displays all connections and listening ports -n : Displays all address and instructions in numerical format (This is required because output from -a can contain machine names)
Then, a find command to "Pattern Match" the output of previous command.
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.
As noted elsewhere: use netstat, with appropriate switches, and then filter the results with find[str]
Most basic:
netstat -an | find ":N"
or
netstat -a -n | find ":N"
To find a foreign port you could use:
netstat -an | findstr ":N[^:]*$"
To find a local port you might use:
netstat -an | findstr ":N.*:[^:]*$"
Where N is the port number you are interested in.
-n
ensures all ports will be numerical, i.e. not returned as translated to service names.
-a
will ensure you search all connections (TCP, UDP, listening...)
In the find
string you must include the colon, as the port qualifier, otherwise the number may match either local or foreign addresses.
You can further narrow narrow the search using other netstat switches as necessary...
Further reading (^0^)
netstat /?
find /?
findstr /?
when I have problem with WAMP apache , I use this code for find which program is using port 80.
netstat -o -n -a | findstr 0.0:80
3068
is PID, so I can find it from task manager and stop that process.
netstat -a -n | find /c "10.240.199.9:8080"
it will give you number of sockets active on a specific IP and port(Server port number)