Home › SSH

ssh: connect to host port 22: Connection timed out — how to fix

ssh: connect to host 203.0.113.10 port 22: Connection timed out

Quick fix: Check the server is up and the IP is right, then open port 22 in the cloud firewall/security group and the server firewall (sudo ufw allow OpenSSH). If SSH runs on another port, use ssh -p 2222 user@host.

Timed out vs refused

Step 1: is the host reachable at all?

ping -c 3 203.0.113.10          # may be blocked, not conclusive
nc -vz -w 5 203.0.113.10 22     # tests the SSH port specifically

Check in your cloud console that the instance is running and the public IP hasn't changed (AWS public IPs change on stop/start unless you use an Elastic IP).

Step 2: cloud firewall

Step 3: firewall on the server

If you can get a console (cloud web console / VNC):

sudo ufw status
sudo ufw allow OpenSSH
sudo systemctl status ssh       # or sshd

Also check firewalld (sudo firewall-cmd --list-all) and iptables -L.

Step 4: SSH on a non-standard port

ssh -p 2222 user@host

Or in ~/.ssh/config:

Host myserver
    HostName 203.0.113.10
    Port 2222
    User ubuntu

Step 5: your network blocks outgoing port 22

Corporate, school and hotel Wi-Fi often block it. Test from another network (phone hotspot). For GitHub specifically, SSH over port 443 works: ssh -T -p 443 git@ssh.github.com.

Other causes

Last updated 2026-10-29.