Networking
Risk: Critical

Port 21 β€” FTP (File Transfer Protocol Control)

Port 21 is the command control port for standard File Transfer Protocol. Data transfer occurs over port 20 or dynamic passive ports.

PORT NUMBER

21

PROTOCOL

TCP

DEFAULT PROCESS

vsftpd, proftpd, pure-ftpd

FIREWALL TARGET

21/tcp

Instant Terminal Fixes for Port 21

macOS & Linux Terminal
1. Check who is listening on port 21:
sudo ss -tulpn | grep :21
2. Kill process occupying port 21 (EADDRINUSE fix):
sudo systemctl stop vsftpd
3. UFW Firewall Allow rule:
sudo ufw deny 21/tcp
Windows PowerShell (Admin)
1. Check listening port:
Get-NetTCPConnection -LocalPort 21
2. Force kill process on port 21:
Stop-Service ftpsvc -Force
3. Docker Port Forwarding Mapping:
docker run -p 21:21 -d fauria/vsftpd

Common Error Encountered

ftp: connect: Connection refused on port 21

Security Advisory & Hardening

FTP transmits usernames and passwords in clear text over the wire. Deprecate FTP in favor of SFTP (SSH Port 22) or FTPS with mandatory TLS.

Frequently Asked Questions

Port 21 Questions & Answers

Common questions regarding default services, kill commands, and firewall configurations.

Port 21 is commonly used for FTP (File Transfer Protocol Control). Port 21 is the command control port for standard File Transfer Protocol. Data transfer occurs over port 20 or dynamic passive ports.