The Ports Most Servers Use
| Port | Service | Open to the internet? |
|---|---|---|
22/ | SSH, SFTP, scp | Yes, with key login |
23/ | Telnet, unencrypted | No |
80/ | HTTP | Yes, web servers |
443/ | HTTPS | Yes, web servers |
443/ | HTTP/3 (QUIC) | Yes, if offered |
25/ | SMTP, server to server | Mail servers only |
587/ | Submission, STARTTLS | Mail servers only |
465/ | Submission, TLS | Mail servers only |
143/ | IMAP | Mail servers only |
993/ | IMAP over TLS | Mail servers only |
110/ | POP3 | Mail servers only |
995/ | POP3 over TLS | Mail servers only |
53/ | DNS | DNS servers only |
853/ | DNS over TLS | DNS servers only |
3306/ | MySQL, MariaDB | No |
5432/ | PostgreSQL | No |
6379/ | Redis | No |
27017/ | MongoDB | No |
21/ | FTP control | Avoid, use SFTP |
990/ | FTPS, implicit TLS | FTP servers only |
873/ | rsync daemon | No, use rsync over SSH |
123/ | NTP time | No, outbound only |
161/ | SNMP | No |
9100/ | Prometheus node exporter | No |
10050/ | Zabbix agent | No |
51820/ | WireGuard | Yes, if used |
1194/ | OpenVPN | Yes, if used |
"No" means the port should be reachable only from the server itself or from your own servers over a private network. These are defaults. Any service can be moved to another port, and any port can carry another service. Why some use TCP and others UDP is explained in TCP vs UDP.
Port Ranges
- System or well-known, 0 to 1023: assigned to standard services. On Linux, by default only root or a program with the right capability can listen on them, which is why web servers start as root and then drop privileges.
- User or registered, 1024 to 49151: IANA registers them for applications on request, such as 3306 for MySQL.
- Dynamic or private, 49152 to 65535: never assigned, left for temporary use.
The names and ranges are defined in RFC 6335.
When your server opens an outgoing connection, the kernel picks a temporary source port, an ephemeral port. Linux takes them from the range in net.ipv4.ip_, by default 32768 to 60999:
sysctl net.ipv4.ip_local_port_rangeEphemeral ports do not need firewall rules for incoming traffic: in a stateful firewall such as ufw or firewalld, replies to your own connections are allowed by connection tracking.
On Your Server: See What Is Listening
sudo ss -tulpnRead the Local Address column of each line:
0.0.0.0:80,[::]:80, or*:80: listening on every address, public ones included.127.0.0.1:6379: reachable only from the server itself.10.10.0.11:5432: reachable on one private address only.
For a single port, sudo lsof -i :443 names the program, as shown in the lsof command. The file /etc/services maps numbers to names: grep -w 5432 /etc/services. To test from another machine whether a port is reachable, run nc -zv 203.0.113.10 443; see the nc command.
Open Only the Ports You Need
A typical web server needs 22, 80, and 443 from the internet and nothing else. Before you turn a firewall on, allow SSH first, keep your current session open, and test a new login in a second terminal. With ufw:
sudo ufw allow 22/tcp
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable
sudo ufw status verboseIf SSH runs on another port, allow that port instead of 22. On AlmaLinux and Rocky Linux, firewalld's default public zone already allows SSH; add --add-service=http and --add-service=https with --permanent, then reload.
Databases Are Not on the List
Ports 3306, 5432, 6379, and 27017 should not be open to the internet. Bind the database to 127.0.0.1 or to a private address, as described in public vs private IP. To work with a database from your own computer, use an SSH tunnel instead of opening the port; see SSH port forwarding. Docker is a special case: traffic to a port published with -p is redirected before ufw's rules see it, so bind such a port to the loopback address, as in -p 127.0.0.1:8080:80.
Changing a Default Port
Moving SSH off port 22 reduces log noise from bots, but it does not replace key login. The safe order of steps is in how to change the SSH port.
Common Errors
- Address already in use: another program already listens on the port. Find it with
sudo ss -tlnpbefore starting the new one. - Works locally, not from outside: the service listens on
127.0.0.1only, or a firewall blocks the port.
Updated:
Linux VPS with Full Root Access
MUVCloud cloud servers run on KVM with Enterprise NVMe SSD storage and full root access, in Turkey, the Netherlands, and the USA.
More Guides
No Limits on Service or Support
You are not on your own as your projects grow. Our support engineers are ready 24/7, on several channels, whenever you need them.

- 100% customer satisfaction goal
- Our own hardware
- 24/7 ticket and email support
- 4 countries with locations