Port 22 (SSH)
Port 22 is the default for SSH (Secure Shell): encrypted remote login to servers, command execution, SFTP file transfer and port forwarding. OpenSSH, the most common server, listens here unless told otherwise.
- Service
- SSH
- Protocol
- TCP
- IANA registry
- Officially assigned: ssh (The Secure Shell (SSH) Protocol), TCP/UDP
Check if a port is open on your IP
We only check the address you are visiting from, one TCP port at a time. You cannot enter someone else’s address: this is not a port scanner.
Is it safe to open port 22?
SSH is encrypted, but a server reachable on port 22 receives constant password-guessing attempts from bots. Use key-based login, set PasswordAuthentication no and PermitRootLogin no in sshd_config, and limit access with a firewall or a VPN. Moving SSH to another port only reduces log noise; it is not protection by itself.
Sources
“Port 22 is already in use”: how to fix it
The error means another program is already listening on port 22. Find its process ID (PID), then stop that program or start yours on a different port.
Windows (Command Prompt or PowerShell as administrator)
netstat -ano | findstr :22taskkill /PID <PID> /FmacOS
lsof -nP -iTCP:22 -sTCP:LISTENkill <PID>Linux
sudo ss -ltnp | grep :22sudo lsof -i :22sudo kill <PID>Replace <PID> with the number from the last column (Windows) or the PID column (macOS, Linux).
How to open port 22
Router: in the router’s admin page find Port Forwarding (sometimes Virtual Server or NAT), forward TCP port 22 to the local IP of the computer running the service, and save.
Windows Defender Firewall (PowerShell as administrator)
New-NetFirewallRule -DisplayName "Port 22 TCP" -Direction Inbound -Action Allow -Protocol TCP -LocalPort 22Linux with ufw
sudo ufw allow 22/tcpLinux with firewalld
sudo firewall-cmd --permanent --add-port=22/tcpsudo firewall-cmd --reloadThen run the check above. If the port is still closed, see why a port can look closed below.
Why a port can look closed when your server is running
Most home networks sit behind a router doing NAT: the router owns the public address, and your computer has a private one such as 192.168.1.10. A connection from the internet reaches the router and stops there unless you add a port forwarding rule to your computer.
Many mobile and some home providers go further and use carrier-grade NAT (CGNAT): several customers share one public address, and your router itself gets an address from 100.64.0.0/10. Then no rule on your side can open a port; ask the provider for a public IP or use a tunnel or VPN service.
Even with forwarding in place, the firewall on the computer (Windows Defender Firewall, ufw, firewalld) must allow the port, and the program must listen on all interfaces (0.0.0.0), not only on 127.0.0.1.
UDP cannot be checked this way: a UDP service usually stays silent to packets it does not understand, so “no answer” means nothing. This check uses TCP only.
Frequently asked questions
What is port 22 used for?
Port 22 is the default for SSH (Secure Shell): encrypted remote login to servers, command execution, SFTP file transfer and port forwarding. OpenSSH, the most common server, listens here unless told otherwise.
Is port 22 TCP or UDP?
Port 22 uses TCP. IANA reserves the number for both TCP and UDP, but in practice only TCP is used.
Is it safe to open port 22?
SSH is encrypted, but a server reachable on port 22 receives constant password-guessing attempts from bots. Use key-based login, set PasswordAuthentication no and PermitRootLogin no in sshd_config, and limit access with a firewall or a VPN. Moving SSH to another port only reduces log noise; it is not protection by itself.
How do I free port 22 if it is already in use?
Find the process: on Windows run netstat -ano | findstr :22 and stop it with taskkill /PID <pid> /F; on macOS or Linux run lsof -i :22 and stop it with kill <pid>.