What counts as an open port?
Three things decide whether a port is open to the world. A program must listen on it, it must bind to an address the outside can reach, and no firewall may drop the traffic on the way in. A database bound to 127.0.0.1 is listening but only reachable from the box itself. A web server on 0.0.0.0:80 is reachable unless the firewall blocks it. Checking all three avoids both false alarms and nasty surprises.
How do I list listening ports on the machine?
sudo ss -tulpn sudo ss -ltn 'sport = :3306'
-t and -u pick TCP and UDP, -l shows listening sockets only, -p adds the owning process and -n keeps numbers instead of service names. The second line uses a filter expression to check one port. The ss command explains the filters in depth; the older The netstat command gives the same answer with netstat -tulpn if you have net-tools installed.
How do I read the Local Address column?
| Local address | Reachable from |
|---|---|
0.0.0.0:443 | Every IPv4 address on the box, so the internet if the firewall allows |
[::]:443 or *:443 | All addresses; on most systems this also accepts IPv4 |
127.0.0.1:6379 | Only programs on the same machine |
203.0.113.10:8080 | Only that one address |
%lo or %eth0 suffix | Bound to a specific interface |
Your machine has one public IPv4 address, so in practice the question is simple: is the service bound to loopback or to everything? Databases, Redis, Memcached and admin panels should usually be on loopback or protected by the firewall.
Which program owns a port?
sudo ss -ltnp | awk 'NR==1 || /:25 /' sudo lsof -nP -iTCP:25 -sTCP:LISTEN sudo fuser -v 25/tcp
Any of the three names the process and PID. Then systemctl status <pid> tells you which service unit started it, so you can disable the unit rather than kill a process that will just come back. More lsof tricks are in lsof command.
Is the firewall letting the port through?
sudo ufw status numbered # Ubuntu, Debian with ufw sudo firewall-cmd --list-all # AlmaLinux, Rocky, CentOS Stream sudo nft list ruleset | less # what the kernel actually enforces
ufw and firewalld are both front ends to nftables in current releases, so nft list ruleset shows the real rules whatever tool wrote them. If ufw is inactive and no other rules exist, every listening port is reachable. On top of your own firewall, our network filters volumetric attacks at the edge, but it does not close ports for you; see Edge DDoS filtering.
How do I test from outside?
The only proof that counts is a connection from another network. From your laptop or a second server:
nc -zv -w 3 203.0.113.10 22 80 443 5432 nmap -Pn --top-ports 300 203.0.113.10 nmap -Pn -sU -p 53,123,161 203.0.113.10
nc -z tries a handful of ports and reports succeeded or refused. nmap scans ranges and classifies each port as open, closed or filtered. Filtered means a firewall dropped the probe; closed means the packet arrived but nothing listens. UDP scans are slow and less certain, so scan only the ports you care about. Scan only machines you own.
What should a fresh server show?
A new box from us with a clean image should list little more than SSH on port 22, plus a local resolver on 127.0.0.53 on Ubuntu and a chrony socket on loopback. Every port you add later should be on purpose. Make a habit of running ss -tulpn after each install; packages such as mail servers, rpcbind or database servers sometimes start listening on all addresses by default. Close what you do not need with Open a port in Linux in reverse, or bind it to loopback in its own config.
Can I watch for new listeners automatically?
sudo ss -Htuln | sort > /root/ports.baseline sudo ss -Htuln | sort | diff /root/ports.baseline - && echo unchanged
Save a baseline once, then run the diff from cron and mail yourself any change. It is a cheap early warning that something new appeared, whether from a package upgrade or from a process that should not be there.
Machines With a Public IPv4 Ready for Your Services
| Server | Processor | Cores / threads | Memory | Storage | Network | Per month | Smallest order |
|---|---|---|---|---|---|---|---|
| E1 | Intel Xeon E3-1240 v3 | 4 / 8 | 16 GB DDR3 | 2x 240 GB SSD | 2x 1 Gbps | $30.52 | $91.56 (3 months) |
| S2 | Intel Xeon E-2356G | 6 / 12 | 64 GB DDR4 | 1x 1 TB NVMe | 2x 10 Gbps | $58.39 | $58.39 (1 month) |
| S3 | Intel Xeon E-2356G | 6 / 12 | 64 GB DDR4 | 2x 1 TB NVMe | 2x 10 Gbps | $80.38 | $80.38 (1 month) |
Keep Reading
The ss command
List sockets fast with ss: listening ports, filters by state, port and address, TCP internals like RTT, summaries and killing stuck sockets.
Openlsof command
Use lsof to see which process holds a file, a port or a deleted log open, and free disk space without a reboot.
OpenOpen a port in Linux
Open a TCP or UDP port on Ubuntu, Debian, AlmaLinux or Rocky with ufw, firewalld or nftables, then prove it works from outside.
OpenFirewall
What a firewall does, packet filters versus stateful and application firewalls, and the Linux tools that set the rules on a dedicated machine.
OpenFAQ
Quick Answers
sudo ss -tulpn. It shows TCP and UDP listeners with the owning process.
A firewall dropped the probe, so nmap cannot tell whether anything listens behind it.
It may be bound to 127.0.0.1, or the firewall drops it. Check the Local Address column and your rules.
On Linux, usually yes, because dual-stack sockets accept IPv4 unless bindv6only is set.
Scanning machines you rent and control is normal maintenance. Do not scan networks you do not own.