What is port 21 used for?
File Transfer Protocol control connection: logins and commands.
Should port 21 be open?
Open only if you need it. Expose it only when required, with encryption and strong authentication, ideally limited to known IP addresses. Plain FTP sends passwords unencrypted. Use SFTP over SSH, or FTPS, and restrict access by IP if you must keep it.
See what is listening on port 21
# Linux
sudo ss -tlnp | grep ':21 '
# macOS
sudo lsof -nP -i TCP:21 -sTCP:LISTEN
# Windows (PowerShell)
Get-NetTCPConnection -LocalPort 21 -State Listen
Open or block port 21 in a firewall
# Ubuntu / Debian (ufw)
sudo ufw allow 21/tcp
sudo ufw deny 21/tcp
# Windows (PowerShell, as administrator)
New-NetFirewallRule -DisplayName "Port 21" -Direction Inbound -Protocol TCP -LocalPort 21 -Action Allow
On cloud servers, also open the port in the provider’s security group or network firewall. At home, a service behind a router needs a port-forwarding rule to the device’s local IP.
Test it from outside
A port can be open on the server but blocked upstream. The Port Checker connects from the internet, so it shows what the world sees. From your own machine, use nc -vz example.com 21 (macOS/Linux) or Test-NetConnection example.com -Port 21 (Windows).