X
X
X
X

Knowledge Base

HomepageKnowledge BaseServer ManagementCheck Open Ports on Linux: Find Lis...

Check Open Ports on Linux: Find Listening Services with ss

In short: The most practical way to check open ports on Linux is the command ss -tulpn. It lists the TCP and UDP ports your server is listening on and the process that opened each one. If the local address is 127.0.0.1, the port is reachable only from the server itself; 0.0.0.0 means it listens on all network interfaces.

How do you check open ports on Linux?

Connect to your server over SSH (see our SSH guide) and run:

ss -tulpn

To see the process names of other users, you usually need sudo ss -tulpn. According to the ss help output, the options mean:

  • -t: show TCP sockets.
  • -u: show UDP sockets.
  • -l: show only listening sockets.
  • -p: show the process using the socket.
  • -n: do not resolve service or host names; print port numbers.

For every option, see the ss manual page.

What do the output columns mean?

The output has these columns: Netid (tcp or udp), State (LISTEN for a listening socket), Recv-Q and Send-Q (queue values), Local Address:Port (the address and port the server listens on), Peer Address:Port (usually 0.0.0.0:* for a listening socket) and Process (process name, pid and file descriptor). The process column looks like users:(("python3",pid=3031,fd=5)).

What is the difference between 127.0.0.1 and 0.0.0.0?

This difference matters for security. For example, when a test server is started on 127.0.0.1, the output looks like this:

State  Recv-Q Send-Q Local Address:Port  Peer Address:Port
LISTEN 0      5          127.0.0.1:18080      0.0.0.0:*

127.0.0.1 means the service can be reached only from inside the server; nobody can connect from the internet. If the same service listened on 0.0.0.0, it would accept connections on all IPv4 interfaces. For IPv6, the output shows * or [::] in the same role. If a service that should not be exposed, such as a database, listens on 0.0.0.0, review its configuration or your firewall rules.

How do you query a specific port or IP version?

ss -tlnp 'sport = :80'
ss -4tln
ss -6tln
ss -s
  • 'sport = :80': filters sockets whose source (local) port is 80. Empty output means nothing is listening on that port.
  • -4 and -6: list only IPv4 or only IPv6 sockets.
  • -s: print summary counts of sockets.

Which ports do you see most often?

Ports you often meet in the output are 22 (SSH), 80 (HTTP), 443 (HTTPS) and 3306 (MySQL and MariaDB). Official port assignments are kept in the IANA service name and port number registry. If you do not recognise a number, look it up there first and then match it with the process name in the Process column. Another program can use the same number, so trust the process rather than the number alone.

What should you do if you see an unexpected port?

  1. Look at the process name and pid. If you installed the service yourself and need it, leave it.
  2. If you do not need it, stop and disable the service; see our systemctl guide for the commands.
  3. If it is needed but only for local use, set its listen address to 127.0.0.1 in its configuration.
  4. Restrict outside access with a firewall: our firewall guide explains the basics.

Remember that ss shows only what the server listens on. Whether a port is reachable from the internet also depends on the firewall. For general security steps on a new server, read our Linux server hardening article.

Frequently Asked Questions

What is the difference between ss and netstat?

Both list network sockets. ss comes with the iproute2 package and is available by default on current Linux distributions; this guide shows the commands with ss.

Why can't I see the process name?

The process column needs the -p option. To see processes that belong to other users you usually have to run the command with sudo.

The port shows as open but I cannot connect from outside. Why?

ss only shows that the server listens on the port. A firewall, cloud provider rules or a listen address of 127.0.0.1 can block outside access.

How do I find the process that listens on a specific port?

Use a filter such as sudo ss -tlnp 'sport = :80'; the Process column shows the name and pid of the process that opened it.

Can't find the information you are looking for?

Create a Support Ticket
Did you find it useful?
(120 times viewed / 0 people found it helpful)

Powered by WISECP
Top