SSH: Connection timed out
Diagnose and fix SSH connection timeout errors caused by firewalls, security groups, or network routing issues.
SSH produces "Connection timed out" when the TCP connection attempt receives no response — typically because a firewall silently drops packets or the server is unreachable at the network layer.
When SSH Produces "Connection timed out"
SSH displays "ssh: connect to host 203.0.113.50 port 22: Connection timed out" after waiting ~60 seconds for a TCP response that never arrives. Unlike "Connection refused" (which is an active rejection), a timeout means packets are being silently dropped.
What Causes "Connection timed out" in SSH
A firewall or cloud security group silently drops packets to port 22. AWS Security Groups, GCP Firewall Rules, and Azure Network Security Groups all block SSH by default until an allow rule is created.
The server's IP address is incorrect or the server is offline. The SSH client sends SYN packets to an IP address that does not route to any active server.
A network routing issue prevents packets from reaching the server. The local machine may lack a default gateway, or an intermediate router may drop traffic.
How to Fix "Connection timed out" in SSH
- Verify basic network connectivity with ping:
ping -c 3 203.0.113.50- Test TCP connectivity to port 22 specifically:
nc -zv 203.0.113.50 22Check cloud security group rules — ensure inbound TCP port 22 is allowed from your IP address.
Verify UFWor iptables on the server allows SSH:
sudo ufw allow sshHow to Verify the Fix
SSH connects without timeout:
ssh -o ConnectTimeout=10 user@203.0.113.50Related SSH Errors
SSH: Connection refused— the server actively rejects the connection, which is faster than a timeout.