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
| Port | Protocol | Service | Open to the internet? |
|---|---|---|---|
| 80 | TCP | HTTP (websites, redirects to HTTPS) | Yes, on web servers |
| 443 | TCP, UDP | HTTPS; HTTP/3 uses UDP | Yes, on web servers |
| 22 | TCP | SSH and SFTP | Yes, but protect it (keys, allow list) |
| 21 | TCP | FTP (unencrypted) | Avoid; use SFTP instead |
| 25 | TCP | SMTP, server-to-server email | Only on mail servers |
| 587 | TCP | Email submission (STARTTLS) | On mail servers |
| 465 | TCP | Email submission (TLS from the start) | On mail servers |
| 993 | TCP | IMAP over TLS (reading email) | On mail servers |
| 995 | TCP | POP3 over TLS | On mail servers |
| 53 | UDP, TCP | DNS | Only on DNS servers |
| 3306 | TCP | MySQL and MariaDB | No: local or private network only |
| 5432 | TCP | PostgreSQL | No: local or private network only |
| 6379 | TCP | Redis | No: local only |
| 2083 | TCP | cPanel (HTTPS) | On cPanel servers |
| 2087 | TCP | WHM (HTTPS) | On cPanel servers |
| 2096 | TCP | cPanel Webmail (HTTPS) | On cPanel servers |
| 3389 | TCP | Windows Remote Desktop | Avoid 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.



