Find out what is listening on a given port

0
2546
Find out what is listening on a given port
Find out what is listening on a given port

To find out what application is listening on a given port on Linux, issue following command:


$ netstat -pntl | grep $PORT

with Mac OS X, the netstat command behaves differently, and you need to provide the protocol via -p option.


$ netstat -p tcp | grep $PORT

Besides, there is another command you can use, lsof.


$ lsof -n -i :$PORT_LIST | grep LISTEN

where $PORT_LIST is a list of ports in comma-separated format. For example,


$ lsof -n -i :80,8000,443 | grep LISTEN

On Windows, you can use netstat, too, but a little difference:


C:\>netstat -a -b -o

with the option -o will provide the process ID that listens to the ports. Or simpler, just use TCPView from Sysinternals package.

Have fun 🙂