> ## Documentation Index
> Fetch the complete documentation index at: https://help.freakhosting.com/llms.txt
> Use this file to discover all available pages before exploring further.

# How to Check Open Ports on Linux with ss and netstat

> Check open ports on Linux with sudo ss -tulpn, which lists every listening TCP and UDP port with the program using it. Includes netstat, lsof and firewall checks.

To check open ports on Linux, run `sudo ss -tulpn`. It lists every TCP and UDP port the server is listening on, the address it listens on and the program that owns it. To check one port, add a filter: `sudo ss -tlnp 'sport = :80'`. On older systems `sudo netstat -tulpn` gives the same list. A listening port is only reachable from outside if your firewall allows it.

| Difficulty | Time | Works on | Needs |
| - | - | - | - |
| Beginner | 5 minutes | Ubuntu 22.04 / 24.04, Debian 12 / 13, AlmaLinux / Rocky 9 / 10 | sudo to see process names |

## Before you start

* [Connect with SSH](https://help.freakhosting.com/portals/other/how-to-connect-to-a-linux-server-with-ssh.md). `ss` works for any user, but only shows which program owns a port when run with `sudo` (root can leave it out).
* A **port** is a numbered door a program uses for network traffic: SSH uses 22, websites 80 and 443. A port is **listening** when a program waits for connections on it.

## How to list all listening ports with ss

```bash theme={null}
sudo ss -tulpn
```

Example output:

```text theme={null}
Netid State  Recv-Q Send-Q Local Address:Port  Peer Address:Port Process
udp   UNCONN 0      0          127.0.0.54:53        0.0.0.0:*     users:(("systemd-resolve",pid=512,fd=16))
tcp   LISTEN 0      4096          0.0.0.0:22        0.0.0.0:*     users:(("sshd",pid=901,fd=3))
tcp   LISTEN 0      511           0.0.0.0:80        0.0.0.0:*     users:(("nginx",pid=1204,fd=6))
tcp   LISTEN 0      80          127.0.0.1:3306      0.0.0.0:*     users:(("mariadbd",pid=1388,fd=22))
tcp   LISTEN 0      4096             [::]:22           [::]:*     users:(("sshd",pid=901,fd=4))
```

| Option | Meaning |
| - | - |
| `-t` | TCP |
| `-u` | UDP |
| `-l` | Listening sockets only |
| `-p` | Show the process |
| `-n` | Show numbers, not service names (`22`, not `ssh`) |

### How to read the Local Address column

| Local Address | Reachable from |
| - | - |
| `0.0.0.0:80` | Every IPv4 address on the server, so the internet (if the firewall allows it) |
| `[::]:80` | Every IPv6 address (often IPv4 too) |
| `203.0.113.10:80` | Only that one IP address |
| `127.0.0.1:3306` or `[::1]:3306` | Only the server itself (localhost) |

In the example, MariaDB on `127.0.0.1:3306` is safe: nothing outside can reach it. A database on `0.0.0.0` is reachable by anyone your firewall lets through.

## How to check one port

```bash theme={null}
sudo ss -tlnp 'sport = :80'
sudo ss -tulpn | grep ':25565'
```

If the command prints only the header line, nothing is listening on that port.

### Which program is using a port?

```bash theme={null}
sudo lsof -i :80 -P -n
```

```text theme={null}
COMMAND  PID     USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
nginx   1204     root    6u  IPv4  58876      0t0  TCP *:80 (LISTEN)
```

Use this when a program fails with "Address already in use". Stop the other program, or move one of them to a different port. If you want to end it, see [kill a process](https://help.freakhosting.com/portals/other/how-to-kill-a-process-on-linux.md).

## How to use netstat (older systems)

`netstat` is part of the older `net-tools` package, which may not be installed. The options are the same:

> [tab] Ubuntu / Debian
>
> ```bash theme={null}
> sudo apt install net-tools
> sudo netstat -tulpn
> ```

> [tab] AlmaLinux / Rocky
>
> ```bash theme={null}
> sudo dnf install net-tools
> sudo netstat -tulpn
> ```

Prefer `ss`: it is installed everywhere (package `iproute2` / `iproute`) and is faster.

## How to see active connections

```bash theme={null}
ss -tn state established
ss -s
```

The first lists open TCP connections with the remote IP and port. `ss -s` prints totals, which helps when you suspect a flood of connections.

## Is a listening port actually open to the internet?

A port in `ss` is listening on the server. Whether the internet can reach it also depends on your firewall:

> [tab] Ubuntu / Debian (ufw)
>
> ```bash theme={null}
> sudo ufw status verbose
> ```

> [tab] AlmaLinux / Rocky (firewalld)
>
> ```bash theme={null}
> sudo firewall-cmd --list-all
> ```

On a VPS, rules you set in the [FREAKHOSTING Firewall panel](https://help.freakhosting.com/portals/firewall/firewall-panel-overview.md) also apply. To test from outside, see [check if a port is open from outside](https://help.freakhosting.com/portals/other/how-to-check-if-a-port-is-open-from-outside.md).

> [!WARNING]
>
> When you open a port, add the rule for the new port before removing an old one, and never remove the rule for your SSH port while connected. If a firewall change locks you out of a VPS, use the [VNC console](https://help.freakhosting.com/portals/vps-panel/how-to-enable-and-use-vnc-console-access.md). Don't open database ports (3306, 5432, 6379, 27017) to the whole internet; allow only the IP addresses that need them.

## How to check it worked

Start a test listener and look for it:

```bash theme={null}
python3 -m http.server 8080 &
sudo ss -tlnp 'sport = :8080'
kill %1
```

You see a `LISTEN` line on `0.0.0.0:8080` owned by `python3`. After `kill %1` it is gone.

## Frequently asked questions

### What is the difference between ss and netstat?

Both list sockets. `ss` is the modern tool from `iproute2`, installed by default and faster on busy servers. `netstat` comes from the older `net-tools` package. The options `-tulpn` work in both.

### Why don't I see the process name?

Run the command with `sudo`. Without root rights, `ss` and `netstat` hide process names for other users' programs.

### How do I find which ports are open from the outside?

Run a scan from another machine you own, for example `nmap -Pn 203.0.113.10`, or use the steps in [check if a port is open from outside](https://help.freakhosting.com/portals/other/how-to-check-if-a-port-is-open-from-outside.md). Only scan servers you are responsible for.

### Why does port 53 show on 127.0.0.53 or 127.0.0.54?

That is `systemd-resolved`, the local DNS cache on Ubuntu. It only listens on the loopback address, so it isn't reachable from outside.

## Related guides

> [card] [VPS and dedicated server guides](https://help.freakhosting.com/portals/other/vps-and-dedicated-server-guides.md)
>
> Every server guide in one place.

> [card] [Check if a port is open from outside](https://help.freakhosting.com/portals/other/how-to-check-if-a-port-is-open-from-outside.md)
>
> Test from the internet.

> [card] [Set up a firewall with UFW](https://help.freakhosting.com/portals/other/how-to-set-up-a-firewall-with-ufw.md)
>
> Open and close ports on Ubuntu.

> [card] [Set up a firewall with firewalld](https://help.freakhosting.com/portals/other/how-to-set-up-a-firewall-with-firewalld.md)
>
> Open and close ports on AlmaLinux.

> [card] [Kill a process](https://help.freakhosting.com/portals/other/how-to-kill-a-process-on-linux.md)
>
> Free a port that is in use.

***

> [!NOTE]
>
> **Checked against the [ss(8) manual from iproute2](https://man7.org/linux/man-pages/man8/ss.8.html)** on 4 November 2026; `ss`, `netstat` and `lsof` tested on Ubuntu 24.04 LTS. Commands can differ on other distributions or releases.

> [!NOTE]
>
> ### Need Extra Help?
>
> If you encounter any issues, our support team is ready to assist:
>
> * **Live Chat:** Quick assistance via our website.
> * **Support Ticket:** [Open a Ticket](https://freakhosting.com/clientarea/submitticket.php)
> * **Discord:** [Join our Community](https://discord.gg/freakhosting)
> * **Email:** [support@freakhosting.com](mailto:support@freakhosting.com)

> [!TIP]
>
> ### Save on Your Hosting
>
> Ready to upgrade your hosting? Use code **KB20** at checkout for **20% off** your first order!

***

**Last Updated:** November 2026


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.