Port 21: FTP control

Port 21 (TCP) is used by FTP control. Commands and login for File Transfer Protocol. Credentials travel in clear text unless FTPS is used.

21Port
TCPProtocol
ftpIANA service name
File transferCategory

Port range

21 is a well-known (system) port (range 0–1023). On Linux and macOS, binding to it traditionally needs root or the CAP_NET_BIND_SERVICE capability.

Security

Only open port 21 to the hosts that need it. Prefer the encrypted variant of the protocol where one exists.

Open port 21 in a firewall

ufw         sudo ufw allow 21/tcp
iptables    sudo iptables -A INPUT -p tcp --dport 21 -j ACCEPT
firewalld   sudo firewall-cmd --permanent --add-port=21/tcp
Windows     New-NetFirewallRule -DisplayName "FTP control 21" -Direction Inbound -Protocol TCP -LocalPort 21 -Action Allow

Check if port 21 is open

nc -vz example.com 21
Test-NetConnection example.com -Port 21   # PowerShell
sudo ss -tulpn | grep ':21 '   # what is listening locally (Linux)

Other file transfer ports

Frequently asked questions

What is port 21 used for?
FTP control. Commands and login for File Transfer Protocol. Credentials travel in clear text unless FTPS is used.
Is port 21 TCP or UDP?
TCP.