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.
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.
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.
To improve upon @EndUzr's response:
To find a foreign port (IPv4 or IPv6) you can use:
netstat -an | findstr /r /c:":N [^:]*$"
To find a local port (IPv4 or IPv6) you can use:
netstat -an | findstr /r /c:":N *[^ ]*:[^ ]* "
Where N is the port number you are interested in. The "/r" switch tells it to process it as regexp. The "/c" switch allows findstr to include spaces within search strings instead of treating a space as a search string delimiter. This added space prevents longer ports being mistreated - for example, ":80" vs ":8080" and other port munging issues.
To list remote connections to the local RDP server, for example:
netstat -an | findstr /r /c:":3389 *[^ ]*:[^ ]*"
Or to see who is touching your DNS:
netstat -an | findstr /r /c:":53 *[^ ]*:[^ ]*"
If you want to exclude local-only ports you can use a series of exceptions with "/v" and escape characters with a backslash:
netstat -an | findstr /v "0.0.0.0 127.0.0.1 \[::\] \[::1\] \*\:\*" | findstr /r /c:":80 *[^ ]*:[^ ]*"
It will give you all active sockets on a specific IP:
netstat -an | find "172.20.1.166"
This will help you
netstat -atn | grep <port no> # For tcp
netstat -aun | grep <port no> # For udp
netstat -atun | grep <port no> # For both
In RHEL 7, I use this command to filter several ports in LISTEN State:
sudo netstat -tulpn | grep LISTEN | egrep '(8080 |8082 |8083 | etc )'
in linux: To find a foreign port you could use:
netstat -anp |grep port|awk '{ print $5 }' |grep port
To find a local port you might use:
netstat -anp |grep port|awk '{ print $4 }' |grep port