Skip to main content
PORT 21 / TCPSecurity & RemoteExposure Risk: High

Port 21: FTP Control — File Transfer Protocol (Command Control)

Primary control port for FTP authentication and commands. Vulnerable to plaintext credential sniffing unless FTPS is enforced.

Default Service
FTP Control
Process: vsftpd
Transport Protocol
TCP
IANA Registered Port 21
Docker Port Flag
-p 21:21
Container to Host Mapping

How to Check & Kill Process on Port 21 (EADDRINUSE Fix)

macOS & Linux (lsof / kill)
# Find process using port 21
sudo lsof -i :21

# Instantly kill process on port 21
lsof -ti:21 | xargs kill -9
Windows (PowerShell & CMD)
# Find PID listening on port 21
netstat -ano | findstr :21

# Force kill by PID
taskkill /PID <PID_NUMBER> /F
Cross-Platform Node.js One-Liner
# Kill port 21 via npx
npx kill-port 21

# Or diagnose via Castov CLI
npx castov fix "EADDRINUSE :::21"
Linux Firewall (UFW) & Connectivity Test
# Test if port 21 is reachable
nc -zv localhost 21

# Allow or deny port 21 in UFW
sudo ufw allow 21/tcp

Frequently Asked Questions about Port 21

What is Port 21 used for?

Port 21 is the standard network port for FTP Control (File Transfer Protocol (Command Control)) operating over TCP. The typical system daemon or process is vsftpd.

How do I kill a process running on Port 21 (EADDRINUSE)?

On macOS and Linux, run: lsof -ti:21 | xargs kill -9 (or npx kill-port 21). On Windows PowerShell/CMD, run: netstat -ano | findstr :21 and then taskkill /PID <PID> /F.

Is it safe to expose Port 21 to the internet?

Port 21 has a High security risk profile. Primary control port for FTP authentication and commands. Vulnerable to plaintext credential sniffing unless FTPS is enforced.

Other Common Network Ports