Check listening ports with netstat

If you’re troubleshooting a service that you know is running normally the next step is to ensure it’s listening on the correct network port.

The netstat command shows the services listening to ports on a Linux server and the details of any connections currently made to them. The connection details to consider during basic network daemon troubleshooting are the addresses that the daemon is listening on (including the port number), the daemon’s process identifier (PID), and the program name.

You need to run netstat on the server that is running the service. Netstat is not affected by your firewall configuration.

Check ports

To list the TCP ports that are being listened on, and the name of each listener’s daemon and its PID, run the following command:

sudo netstat -plnt

The following example shows the output for three common programs that are listening on three different sockets.

Filter the list

If the list of listening daemons is long you can use grep to filter it. For example, to filter out everything except the default web server port, 80, run the following command:


sudo netstat -plnt | grep ':80'