Skip to content
Log In Sign Up info@muvcloud.com

The Ports Most Servers Use

PortServiceOpen to the internet?
22/tcpSSH, SFTP, scpYes, with key login
23/tcpTelnet, unencryptedNo
80/tcpHTTPYes, web servers
443/tcpHTTPSYes, web servers
443/udpHTTP/3 (QUIC)Yes, if offered
25/tcpSMTP, server to serverMail servers only
587/tcpSubmission, STARTTLSMail servers only
465/tcpSubmission, TLSMail servers only
143/tcpIMAPMail servers only
993/tcpIMAP over TLSMail servers only
110/tcpPOP3Mail servers only
995/tcpPOP3 over TLSMail servers only
53/udp+tcpDNSDNS servers only
853/tcpDNS over TLSDNS servers only
3306/tcpMySQL, MariaDBNo
5432/tcpPostgreSQLNo
6379/tcpRedisNo
27017/tcpMongoDBNo
21/tcpFTP controlAvoid, use SFTP
990/tcpFTPS, implicit TLSFTP servers only
873/tcprsync daemonNo, use rsync over SSH
123/udpNTP timeNo, outbound only
161/udpSNMPNo
9100/tcpPrometheus node exporterNo
10050/tcpZabbix agentNo
51820/udpWireGuardYes, if used
1194/udpOpenVPNYes, 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_local_port_range, by default 32768 to 60999:

sysctl net.ipv4.ip_local_port_range

Ephemeral 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 -tulpn

Read 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 verbose

If 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 -tlnp before starting the new one.
  • Works locally, not from outside: the service listens on 127.0.0.1 only, 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.

Cloud VPS Plans Starting at2.99 $/mo Cheap Linux VPS

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.

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