FTP, the File Transfer Protocol, uses port 21. IANA registers ftp on TCP port 21 as the File Transfer Protocol control channel, defined by RFC 959. Port 20 carries file data in active mode, while passive mode uses a server-chosen high port. Plain FTP sends usernames, passwords and files in clear text, so use SFTP on port 22 or FTPS instead.
Key takeaways
- Port 21 is FTP's control channel; file data travels on port 20 in active mode or a high port in passive mode.
- Plain FTP sends usernames, passwords and files in clear text, so anyone on the path can read them.
- Use SFTP on port 22 for most work, or explicit FTPS on port 21 when a partner requires FTP with TLS.
If you see port 21 open on a server, you have found FTP. That one fact tells you a lot: the service dates to 1985, it was built for a trusted network, and it encrypts nothing — including the password.
Which network protocol uses port 21?
FTP, the File Transfer Protocol, uses port 21. IANA registers the service name ftp on TCP port 21 with the description "File Transfer Protocol [Control]", referencing RFC 959.
Port 21 is the control channel. It stays open for the whole session and carries the login, the commands and the replies. The files themselves travel on a second connection: port 20 in active mode, or a server-chosen high port in passive mode. That split is the key to understanding almost every FTP problem.
FTP is a well-known port, in the range 0 to 1023, which is why it is assigned rather than chosen at random. When a client wants to talk FTP, it connects to port 21 first, and the server greets it with a 220 reply.
You can verify the assignment in the IANA port registry entry for port 21.
The protocol itself is defined in RFC 959, File Transfer Protocol, published in October 1985.
How does FTP work?
FTP is a client-server protocol from 1985, defined by RFC 959. The client connects to the control port, logs in with a username and password, then issues commands such as LIST, RETR to download a file, and STOR to upload one.
Each command gets a numbered reply from the server. A 220 means the service is ready, 331 means the username was accepted and a password is needed, and 230 means the login succeeded. Directory listings and file transfers each open a fresh data connection, which is why a firewall has to allow more than just port 21.
Active mode
In active mode, the server connects back to the client on port 20 for data. That worked in the early internet, but it fails behind most modern firewalls and NAT, because the inbound connection looks unsolicited.
Passive mode
In passive mode, the client opens both connections. The server tells the client which high port to use for data, and the client connects to it. This is what almost every client uses today, and it means the firewall must allow a whole range of high ports, not just port 21.
Is FTP secure?
No. Plain FTP has no encryption at all. The username, the password, the commands and the file contents all cross the network as readable text, as RFC 2577 on FTP security considerations explains.
Anyone who can see the packets can read the login: a shared Wi-Fi network, a compromised router, or any hop between the client and the server. A captured FTP password is often also a shell or hosting password, because the FTP account is usually a real account on the server.
There is also no integrity check. An attacker who can modify packets in transit can change a file during download, and neither end will notice. And because FTP accounts are often old, shared and weakly passworded, internet-facing FTP servers face password guessing around the clock.
FTP vs SFTP vs FTPS: what is the difference?
The three names sound alike, but only two of them protect anything. FTPS is FTP made secure; SFTP is a different protocol that happens to share three letters.
| FTP | FTPS | SFTP | |
|---|---|---|---|
| Full name | File Transfer Protocol | FTP over TLS | SSH File Transfer Protocol |
| Default port | 21 | 21 explicit, 990 implicit | 22 |
| Encryption | None | TLS on control and data | Full SSH encryption |
| Connections | Two: control plus data | Two, both encrypted | One |
| Authentication | Username and password | Username, password, certificate | Password or SSH key |
| Firewall | Poor: needs a port range | Poor: TLS hides the data ports | Excellent: one port |
| Defined by | RFC 959 (1985) | RFC 4217 (2005) | SSH subsystem, RFC 4254 |
Explicit FTPS starts in clear text on port 21 and upgrades with the AUTH TLS command, as RFC 4217 defines. Implicit FTPS starts TLS from the first byte, conventionally on port 990, but no RFC standardizes that mode. SFTP runs as a subsystem inside an SSH session, so if SSH is already running on the server, SFTP is already available.
For most new work, SFTP with key-based authentication is the simplest secure choice. Use FTPS only when a partner or a regulation requires it, and use HTTPS uploads when the client is a browser or an application calling an API.
What other ports sit near port 21?
Port 21 is one entry in a small set of well-known file and remote-access ports. Knowing the neighbors helps you read a scan result or a firewall rule without guessing.
| Port | Protocol | What it does |
|---|---|---|
| 20 | FTP data | Default data channel in active FTP |
| 21 | FTP control | Login and commands; clear text |
| 22 | SSH / SFTP | Encrypted shell and file transfer |
| 23 | Telnet | Remote login; clear text, avoid it |
| 69 | TFTP | Simple file transfer over UDP, no login |
| 990 | FTPS implicit | FTP with TLS from the first byte |
| 989 | FTPS data | Data channel for implicit FTPS |
Telnet on port 23 has the same clear-text problem as FTP, and TFTP on port 69 has no authentication at all. If you see any of these open on a public address, treat them the same way: close them or replace them with an encrypted equivalent. You can check the public side of a site with the free SSL checker to confirm it serves over encrypted HTTPS.
How do you check if port 21 is open?
Check from outside your own network, because a port that looks closed from inside may still be open to the internet. A scan, your firewall rules, and the server's listening services should all agree.
Note the last step in the figure: the text at step 4 sits in the right-hand card, so read the card, not the position. If FTP was ever used, change the password even if you close the port today, because the password may already have been seen in transit.
Also check your hosting control panel. Many hosts enabled FTP by default years ago and left it on. Disabling FTP in the panel, removing the FTP accounts, and closing port 21 in the firewall are three separate steps, and all three matter.
How do you move from FTP to SFTP?
Migration is usually a small job, because SFTP needs no new server: it runs inside SSH, which most Linux servers already have. The work is in accounts, keys and firewall rules.
- Confirm SSH is running on the server and that you can log in with it. If SSH works, SFTP works.
- Create SSH keys for each person or system that transfers files, and disable password login for those accounts where you can.
- Restrict each account to its own directory, so a compromised file-transfer account cannot read the rest of the server.
- Update scripts and clients to connect on port 22 with SFTP instead of port 21 with FTP. Test one transfer end to end before changing the rest.
- Close port 21 in the firewall, disable the FTP service, and remove the old FTP accounts.
- Rotate every password that was ever used over plain FTP, and check the site for unexpected files, which may have arrived through a guessed FTP login.
If a partner can only do FTP, put explicit FTPS in front of it and require TLS for both control and data, with certificate checks turned on. Do not accept a setup that silently falls back to plain FTP. For background on securing the rest of a small network, see our guide to how to secure your Wi-Fi.
The bottom line
Port 21 is FTP's control channel, defined by RFC 959 and registered by IANA. It is also a clear-text protocol from 1985 that sends your password where anyone on the path can read it.
Close port 21 unless you have a specific, encrypted reason to keep it. Use SFTP on port 22 for almost everything, and check the result with the free DNS lookup and your firewall rules to confirm nothing is still listening where it should not be.
Frequently asked questions
Which network protocol uses port 21?
FTP, the File Transfer Protocol, uses port 21. IANA lists ftp on TCP port 21 as the control channel, with the file data moving on a separate connection. The protocol is defined by RFC 959, published in October 1985.
Is port 21 TCP or UDP?
FTP on port 21 is TCP in practice. IANA also registers the service for UDP and SCTP, but real FTP needs the ordered, reliable stream that TCP provides, and clients connect to TCP port 21.
What is port 20 used for?
Port 20 is ftp-data, the default data port in active mode FTP. In passive mode, which most clients use today, the server picks a high-numbered port for each transfer instead of port 20.
Is port 21 safe to open?
No, not for plain FTP. It exposes clear-text logins to anyone on the network path, attracts constant password guessing, and a guessed login often gives write access to a website. Close it and use SFTP on port 22 instead.
What is the difference between FTP and SFTP?
FTP is the original protocol on port 21 with no encryption. SFTP is a different protocol that runs inside an SSH session on port 22, so commands and files are encrypted on one connection. Despite the similar name, SFTP is not FTP with encryption added.
What is FTPS?
FTPS is FTP with TLS encryption added. Explicit FTPS starts on port 21 and upgrades with an AUTH TLS command, as defined by RFC 4217. Implicit FTPS starts TLS immediately, conventionally on port 990.
How do I check if port 21 is open?
Use a port scan from outside your network, or check your firewall and server configuration for a listening FTP service. If you find port 21 open on a public address, treat it as a finding and replace the service with SFTP.
Why does FTP use two ports?
FTP separates control from data. Port 21 carries commands and logins for the whole session, while each file transfer or directory listing opens a second connection for the data. That split is why FTP is hard to firewall.
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 and RFC 959, RFC 2577 and RFC 4217.
How we write and fact-check →