Networking & DNS

Common server ports explained: 21, 22, 25, 465, 587, 993, 995, 3306 and 53

A plain-English reference to the ports every hosting server uses besides HTTP: FTP, SSH, SMTP submission, IMAP, POP3, MySQL and DNS, with what to open and what to keep closed.

BeginnerLinux VPS and hosting3 min read

Besides web traffic on 80 and 443, a hosting server listens on a handful of well-known server ports for file transfer, remote login, email, databases and DNS. Knowing what each port does tells you what to open in the firewall, what to restrict, and where to look when a mail client or FTP program cannot connect.

Before you start

Quick reference table

PortServiceEncrypted?Open publicly?
21/TCPFTP controlOptional (FTPS via AUTH TLS)Only if you use FTP
22/TCPSSH and SFTPYesYes, but restrict or use keys
25/TCPSMTP server-to-serverSTARTTLSYes on mail servers
465/TCPSMTP submission (implicit TLS)YesYes on mail servers
587/TCPSMTP submission (STARTTLS)YesYes on mail servers
993/TCPIMAPSYesYes on mail servers
995/TCPPOP3SYesYes on mail servers
3306/TCPMySQL / MariaDBOptionalNo, keep private
53/UDP+TCPDNSNo (plain DNS)Only on name servers

Port 21: FTP

FTP uses port 21 for commands and a separate range of passive ports (for example 30000–35000 on cPanel servers) for the actual data. If login works but directory listing hangs, the passive range is blocked. Always use explicit FTPS (FTP with TLS) or, better, SFTP on port 22.

Port 22: SSH and SFTP

SSH gives you a shell; SFTP is file transfer over the same connection, so it needs no extra ports. Port 22 is scanned constantly. Use SSH keys, disable password login, and add Fail2ban or allow it only from your IPs. Moving SSH to another port cuts log noise but is not real security on its own.

Port 25: SMTP between servers

Mail servers deliver to each other on port 25. Clients should not use it to send. Many cloud and VPS networks block outbound 25 to stop spam; see port 25 blocked on a VPS.

Ports 465 and 587: sending mail from apps and clients

Both are submission ports that require authentication. 465 starts encrypted from the first byte (implicit TLS); 587 starts in plain text and upgrades with STARTTLS. Either is fine; current standards prefer 465. Use one of these in Outlook, Thunderbird, phones and WordPress SMTP plugins.

Ports 993 and 995: reading mail

993 is IMAP over TLS (mail stays on the server and syncs across devices). 995 is POP3 over TLS (mail is downloaded, usually to one device). The unencrypted versions, 143 and 110, should not be used across the internet. Settings for MdmHost mailboxes are in cPanel email ports.

Port 3306: MySQL and MariaDB

Websites on the same server connect to the database through localhost or a Unix socket, so 3306 does not need to be public at all. If a remote app must connect, allow only that IP in the firewall and in the database user's host. An open 3306 invites password guessing and data theft.

Port 53: DNS

DNS answers on UDP 53 for normal queries and TCP 53 for large answers and zone transfers. Open it only on servers that are authoritative name servers. Never run an open recursive resolver on a public IP; it gets abused for amplification attacks.

Check what is listening

sudo ss -tulpn

Anything listening on 0.0.0.0 or [::] is reachable from every network unless the firewall blocks it. Services that should be private should listen on 127.0.0.1.

FAQ about server ports

Which ports should a basic web VPS expose?

22, 80 and 443 (plus UDP 443 for HTTP/3). Add mail, FTP or DNS ports only if you run those services.

Should I use 465 or 587?

Either works. Use whatever your client or host recommends; both encrypt the session.

Why can my mail client receive but not send?

Usually the outgoing port is blocked by your ISP or you used 25. Switch to 465 or 587 with authentication.

Next steps

Was this guide helpful?

Still stuck?

Ask MdmHost AI for a quick answer, or open a ticket and our team will take a look. We are here 24/7.