Linux SSH Connection Refused — Port 22
Errornetwork
Overview
SSH 'Connection refused' on port 22 means the SSH server is not running, the port is blocked, or SSH is configured on a different port.
Key Details
- TCP connection to port 22 is actively refused by the target
- Different from 'Connection timed out' which means the port is filtered/blocked
- The SSH daemon (sshd) must be running on the target machine
- Firewall rules may block port 22 even if sshd is running
- SSH may be configured on a non-standard port for security
Common Causes
- SSH server (sshd) not installed or not running
- Firewall (iptables/nftables/ufw) blocking port 22
- SSH configured on a non-standard port
- TCP Wrappers (/etc/hosts.deny) blocking the client IP
- SELinux policy blocking SSH connections
Steps
- 1Check if sshd is running: systemctl status sshd (or ssh on Debian/Ubuntu)
- 2Start SSH: sudo systemctl start sshd && sudo systemctl enable sshd
- 3Check firewall: sudo ufw status or sudo iptables -L -n | grep 22
- 4Allow SSH through firewall: sudo ufw allow 22 or sudo firewall-cmd --add-service=ssh --permanent
- 5Check SSH port: grep Port /etc/ssh/sshd_config — connect with ssh -p PORT user@host
Tags
linuxsshconnection-refusedport-22remote
More in Network
windows-651-pppoe-connection-failedWindows Error 651 — PPPoE Connection Failed
Warningwindows-691-authentication-failedWindows Error 691 — Authentication Failed
Warningwindows-720-ppp-connection-failedWindows Error 720 — PPP Connection Failed
Errorwindows-800-vpn-tunnel-failedWindows Error 800 — VPN Tunnel Failed
Warningwindows-network-error-619Windows VPN Error 619 — Connection Could Not Be Established
Warningwindows-network-error-868Windows VPN Error 868 — Remote Server Not Resolved
WarningFrequently Asked Questions
Refused means the server actively rejected the connection (nothing listening on port 22). Timed out means a firewall silently dropped the packets.