Skip to content
Free website migration on every plan, done by our team.Learn more ›
Security

Network ports explained: 80, 443, 22, 25 and the rest

What a network port is, the ports websites, email, SSH, databases and cPanel use, which ones should be open on a server, and how to check.

Short answer: An IP address finds a server; a port number finds the service on it. Websites use port 80 (HTTP) and 443 (HTTPS), SSH and SFTP use 22, email between servers uses 25 and email apps send on 587 or 465. A server should only have the ports it needs open to the internet; databases such as MySQL (3306) should not be among them.

If an IP address is a building, ports are the numbered doors. There are 65,536 of them (0 to 65,535). Ports 0 to 1023 are the "well-known" ones used by standard services; the rest are used by other software and for the temporary side of connections.

TCP and UDP

Ports come in two kinds:

  • TCP sets up a connection and makes sure everything arrives in order. Websites, SSH and email use TCP.
  • UDP sends packets without a connection, which is faster for some jobs. DNS queries mostly use UDP, and HTTP/3 (QUIC) runs on UDP port 443. See HTTP/3 explained.

The ports you will meet running a website

PortProtocolServiceOpen to the internet?
80TCPHTTP (websites, redirects to HTTPS)Yes, on web servers
443TCP, UDPHTTPS; HTTP/3 uses UDPYes, on web servers
22TCPSSH and SFTPYes, but protect it (keys, allow list)
21TCPFTP (unencrypted)Avoid; use SFTP instead
25TCPSMTP, server-to-server emailOnly on mail servers
587TCPEmail submission (STARTTLS)On mail servers
465TCPEmail submission (TLS from the start)On mail servers
993TCPIMAP over TLS (reading email)On mail servers
995TCPPOP3 over TLSOn mail servers
53UDP, TCPDNSOnly on DNS servers
3306TCPMySQL and MariaDBNo: local or private network only
5432TCPPostgreSQLNo: local or private network only
6379TCPRedisNo: local only
2083TCPcPanel (HTTPS)On cPanel servers
2087TCPWHM (HTTPS)On cPanel servers
2096TCPcPanel Webmail (HTTPS)On cPanel servers
3389TCPWindows Remote DesktopAvoid exposing; use a VPN

Which ports should be open

The safe default on a server is: block everything coming in, then allow only what you use. A typical web server on a VPS needs 80, 443 and SSH, nothing else. Databases, caches and admin tools should listen on 127.0.0.1 (the server itself) or a private network, never on a public address, because bots scan the whole internet for open database ports every day.

A few points that trip people up:

  • Moving SSH off port 22 cuts down log noise from bots but is not real protection. Use SSH keys and limit who can connect. See how to use SSH and brute-force attacks.
  • Port 25 is often blocked on home and mobile connections and on many cloud networks, to stop spam. Email apps should send on 587 or 465 with a username and password.
  • FTP sends passwords unencrypted. Use SFTP (over SSH, port 22) instead; see FTP vs SFTP.

How to check which ports are open

On a Linux server, list what is listening and on which address:

sudo ss -tulpn

Lines showing 0.0.0.0:3306 or [::]:3306 mean MySQL is listening on every address; 127.0.0.1:3306 means only the server itself can reach it. Then check your firewall with sudo ufw status (see the UFW guide and what a firewall does).

To test from outside, port scanners such as nmap show what the internet can reach. Only scan servers you own or are allowed to test.

Frequently asked questions

What is the difference between port 80 and 443?

Port 80 serves plain HTTP; port 443 serves HTTPS, which is encrypted. Websites keep 80 open only to redirect visitors to 443.

Why can't I send email from my website on port 25?

Many providers block outgoing port 25 to fight spam. Send through an authenticated mail server on port 587 or 465 instead. See what SMTP is and why WordPress isn't sending email.

Is it safe to open port 22?

It is common and fine with the right setup: SSH keys instead of passwords, no root login with a password, and ideally an allow list of your own IP addresses.

Should my database port be open?

No. Keep MySQL, PostgreSQL and Redis on the server itself or a private network. If an app elsewhere needs the database, use an SSH tunnel or a private network between the servers.

Ready when you are

Host it where it performs

NVMe speed, offshore privacy and a written SLA — live in minutes on AuroxHost.