Port 21 is the TCP port assigned to FTP, the File Transfer Protocol, for its control connection. IANA lists ftp on port 21, citing RFC 959. It carries the username, password, and commands such as LIST, RETR, and STOR, while file data travels on a separate connection, port 20 in active mode or a high port in passive mode. Plain FTP encrypts nothing, so use SFTP on port 22 or FTPS with TLS instead.
Key takeaways
- Port 21 is the FTP control port for logins and commands; files travel on a separate data connection.
- Plain FTP sends passwords and files in clear text, so port 21 must never be exposed without TLS.
- SFTP on port 22 is the usual replacement, while explicit FTPS keeps FTP with TLS on port 21.
Port 21 is the front door of FTP, the File Transfer Protocol. A client connects to it, logs in, and issues commands, while the files themselves travel on a separate connection. The problem is that plain FTP encrypts nothing, so that front door is wide open to anyone listening.
What is port 21?
Port 21 is the TCP port assigned to FTP, the File Transfer Protocol, for its control connection. IANA lists the service name ftp on port 21, with the description File Transfer Protocol [Control], and cites RFC 959 as the defining standard.
Port 21 is a well-known port, in the range 0 to 1023 that IANA reserves for common services. A well-known port means that FTP clients know where to connect without being told: they connect to port 21 on the server by default.
The port itself does not transfer files. It carries the conversation: the username and password, the commands such as LIST, RETR, and STOR, and the server replies. The actual file data moves on a separate data connection, which is why FTP is unusual among protocols.
FTP dates to the early internet. RFC 959, published in October 1985, is the official specification, and its roots go back to file transfer proposals from 1971. It was designed for a trusted network, and it has no encryption of its own.
How does FTP use port 21?
FTP splits every session in two. The control connection to port 21 stays open for the whole session and carries commands. Each file transfer or directory listing opens a second, separate data connection.
A typical session goes like this. The client opens a TCP connection to the server port 21. The server greets it, the client sends USER and PASS, and the server accepts the login. The client then sends commands such as PWD to print the directory, LIST to list files, and RETR to download a file.
For each transfer, the client and server agree on a data connection. In active mode, the client sends a PORT command naming the address and port it will listen on, and the server opens the data connection back to the client, usually from its port 20. In passive mode, the client sends PASV, the server replies with a high-numbered port, and the client opens the data connection to that port.
Passive mode is the norm today, because active mode needs the server to open an inbound connection to the client, and home routers and firewalls usually block that. The cost is that the server must open a range of high ports for passive data connections, and the firewall must allow them.
Because the control and data connections are separate, FTP is harder to firewall than a single-connection protocol. A firewall that only allows port 21 will let the login succeed and then watch the transfer fail, which is the most common FTP troubleshooting problem.
What is the difference between port 20 and port 21?
Port 21 is the FTP control port, and port 20 is the FTP data port in active mode. IANA lists ftp-data on port 20 and ftp on port 21, and the two work as a pair in classic FTP.
Port 21 handles the session: login, commands, and replies. It stays open from login to logout. Port 20 is used only in active mode, as the source port when the server opens the data connection back to the client.
In passive mode, port 20 is not used at all. The data connection goes to a high-numbered port chosen by the server, usually in the range above 1023. That is why a passive FTP server needs a defined passive port range in its configuration and in its firewall rules.
Confusing the two is a common mistake. Opening only port 21 lets clients log in but not transfer files. Opening only port 20 does nothing on its own, because no client connects to port 20 to start a session.
| Port | Service | Used for | When |
|---|---|---|---|
| 20 | ftp-data | Data in active mode | Server calls back to client |
| 21 | ftp | Control: login and commands | Every FTP session |
| 22 | ssh | SFTP, a different protocol | Secure file transfer |
| 990 | ftps | Implicit FTPS control | TLS from the first byte |
| 989 | ftps-data | Implicit FTPS data | With port 990 |
Is port 21 secure?
No. Plain FTP on port 21 is not secure, because it sends usernames, passwords, commands, and file contents in clear text. Anyone who can watch the traffic, on the same Wi-Fi network, at an internet provider, or anywhere along the path, can read all of it.
That includes the password. It travels in the clear on the control connection, so a single captured session gives an attacker a working login. It also includes the files, which travel in the clear on the data connection.
FTP also has no strong server authentication by default. A client cannot easily tell whether it is talking to the real server or an impostor, which makes FTP a poor choice for sensitive data or for transfers over the public internet.
An open port 21 on a public address is one of the clearest findings a security audit can produce. It tells an auditor that the server still runs an unencrypted service from the 1980s, and that it should be replaced or protected with TLS.
That does not mean FTP has no place at all. On an isolated internal network, for public files that need no secrecy, or for legacy equipment that supports nothing else, plain FTP can still work. But it should never carry passwords or sensitive files across the internet, and it should never be exposed to the public internet without TLS.
What is the difference between FTP, FTPS, and SFTP?
FTP, FTPS, and SFTP sound alike, but they are different protocols with different ports. FTPS is FTP with TLS added. SFTP is not FTP at all: it is a subsystem of SSH.
FTP uses TCP port 21 for control and port 20 or a high port for data. Nothing is encrypted. It is defined by RFC 959.
FTPS is FTP with TLS. Explicit FTPS starts on port 21 in the clear, then the client sends AUTH TLS and the session upgrades to encrypted, as defined by RFC 4217. Implicit FTPS starts TLS immediately, conventionally on port 990 for control and 989 for data. Explicit FTPS is the modern standard; implicit FTPS is older and still common on managed file transfer platforms.
SFTP is the SSH File Transfer Protocol. It runs as a subsystem inside an SSH session on TCP port 22, so commands and file data share one encrypted connection. There is no second connection, no passive port range, and no clear-text stage.
For a new deployment, SFTP is almost always the right answer. It is simpler to firewall, because it needs only port 22, and it is easier to explain to a firewall team. FTPS is the right choice when you must stay compatible with FTP clients and workflows, and you can add TLS certificates to the server.
Do not confuse SFTP with FTPS when you configure a firewall. SFTP needs port 22, not port 21. FTPS needs port 21 or 990, plus a passive data port range. Mixing them up is a common cause of failed transfers.
What uses port 21?
Port 21 shows up wherever files are still moved the traditional way. Web hosting, legacy systems, printers, scanners, and NAS devices are the most common places you will find it.
Many web hosts still offer FTP for uploading site files, although most now prefer SFTP. Older hosting panels and content management workflows were built around FTP, and some have never been updated.
Legacy business systems, industrial equipment, and medical devices sometimes support only plain FTP for exporting logs, scans, or reports. Replacing those systems is expensive, so FTP survives in corners of networks that were never redesigned.
Common FTP server software includes vsftpd, ProFTPD, Pure-FTPd, FileZilla Server, and the FTP service in Microsoft IIS. If you see port 21 open on a scan, one of these, or a NAS or printer with a built-in FTP service, is usually the cause.
You can check whether your own site uses HTTPS correctly with our free SSL checker.
You can also review its headers with the security headers checker. Neither tests FTP, but both show whether the public-facing side of your site follows modern practice.
IANA is the authoritative source for the assignment. See the IANA port registry entry for port 21, which lists ftp with the description File Transfer Protocol [Control].
How do I check if port 21 is open?
Checking whether port 21 is open is a useful security task, but only do it on systems you own or have permission to test. Scanning someone else network without permission is unauthorized access.
On your own server, check which service is listening. On Linux, a command such as ss -tlnp will show listening TCP ports and the process behind each one. On Windows, netstat -ano shows the same information with process IDs.
From another machine on the same network, you can test the port with a simple connection attempt. A telnet or netcat connection to port 21 should show the FTP server greeting banner if the port is open, including the server software name and version, which is itself information an attacker can use.
From outside your network, use an online port checker or a scan from a trusted external host, and check your public IP address, not your private one. If port 21 answers from the internet, it is exposed, and you should close it or replace it with FTPS or SFTP immediately.
If a transfer fails but the login works, the problem is usually the data connection, not port 21. Switch the client to passive mode, check that the server passive port range is open in the firewall, and confirm that TLS is not hiding the PASV reply from a firewall that inspects FTP traffic.
How do I secure port 21?
The best way to secure port 21 is to stop using plain FTP. Move to SFTP on port 22, or to explicit FTPS on port 21 with TLS required. If you cannot move yet, harden what you have and limit who can reach it.
- Require TLS. For FTPS, require AUTH TLS and encrypted data connections. Do not allow plain FTP logins alongside FTPS, because attackers will simply choose the plain option.
- Do not expose it to the internet. Put FTP behind a VPN or an internal network, and block port 21 at the firewall for public addresses. If a partner needs file access, give them SFTP instead.
- Use strong, unique accounts. Give each user their own FTP account, with a long unique password, and never use the anonymous account unless the files are truly public.
- Limit the passive port range. Define a small range, such as 10 ports, open only that range in the firewall, and log connections to it.
- Hide the banner and keep the software updated. Turn off detailed version banners where you can, and patch the FTP server like any other internet-facing service.
- Log and monitor. Log logins, failed logins, and file transfers, and alert on bursts of failed logins, which suggest a brute force attack.
If you run FTP for a legacy device that cannot do TLS, isolate that device on its own network segment, allow FTP only from the specific hosts that need it, and plan a replacement. A legacy exception should be documented, time-limited, and reviewed, not left open forever.
For a wider check of your public services, our guide to securing your Wi-Fi covers the home network side.
The spear phishing guide shows how attackers use stolen credentials once they have them.
RFC 959 is the official FTP specification. Read RFC 959: File Transfer Protocol for the control and data connection definitions.
The bottom line
Port 21 is the FTP control port: it carries logins and commands, while files travel on a separate data connection. Plain FTP sends everything in clear text, so port 21 should never be exposed to the internet without TLS.
For new file transfer, use SFTP on port 22. If you must keep FTP, use explicit FTPS on port 21 and require TLS. Check your site is serving HTTPS correctly with the free SSL checker.
Frequently asked questions
What is port 21 used for?
Port 21 is used for the FTP control connection. A client connects to TCP port 21, logs in, and sends commands. The files themselves move on a separate data connection, on port 20 in active mode or on a server-chosen high port in passive mode.
Is port 21 TCP or UDP?
FTP on port 21 is TCP in practice. IANA also registers port 21 for UDP and SCTP, but real FTP clients and servers use TCP only.
What is the difference between port 20 and port 21?
Port 21 is the control port for logins and commands. Port 20 is the data port used in active mode, when the server opens the data connection back to the client. In passive mode, port 20 is not used.
Is it safe to open port 21?
No, not for plain FTP. It sends usernames, passwords, and files in clear text, so anyone watching the traffic can read them. If you need file transfer, use SFTP on port 22 or FTPS with TLS, and never expose plain FTP to the internet.
What is FTPS port 990?
Port 990 is the control port for implicit FTPS, where TLS starts immediately, before any FTP commands. Explicit FTPS instead starts on port 21 and upgrades to TLS with the AUTH TLS command.
Is SFTP the same as FTP on port 21?
No. SFTP is a subsystem of SSH that runs on TCP port 22. It is a different protocol from FTP, with one encrypted connection for both commands and data, and it does not use port 21 at all.
Why does my FTP login work but transfers fail?
The login uses port 21, but transfers use a separate data connection. The usual cause is a firewall blocking the data connection. Switch the client to passive mode and check that the server passive port range is open.
Should I close port 21 on my router?
Yes, unless you run a specific service that needs it. Port 21 should not be forwarded to the internet for plain FTP. Close the forward, and use SFTP or a VPN for remote file access instead.
Sources
The engineers and analysts who build Cysoro's domain scanner, email-authentication checks and free security tools. We test what we write about every day — SPF, DKIM, DMARC, certificates, look-alike domains and phishing — and check each guide against the relevant standards, government guidance and vendor documentation.
Checked against the IANA port registry, RFC 959, and RFC 4217 for FTPS.
How we write and fact-check →