Connection timed out

SSH Connection Timed Out on Linux – Quick Fix

Linux & Unix Beginner 👁 11 views 📅 Jun 24, 2026

Your SSH client says "Connection timed out" after waiting. This usually means the port is blocked, the IP is wrong, or the server isn't listening. Let's fix it step by step.

When This Error Happens

You type ssh user@192.168.1.100, press Enter, and then wait. After 30-60 seconds you get: ssh: connect to host 192.168.1.100 port 22: Connection timed out. This often happens when you're trying to SSH into a fresh server setup, after a reboot, or when you changed the network config. I've seen it most on Ubuntu 22.04 and CentOS Stream 9 boxes where the firewall kicks in by default.

Root Cause

The timeout means your client sent a TCP SYN packet to port 22 on the server, but never got a SYN-ACK back. This is different from "Connection refused" (where the port is open but no SSH daemon is listening). Here, the packet is either dropped by a firewall, blocked by a router, or the server's IP is unreachable. 90% of the time it's the firewall on the server itself.

Fix It Step by Step

Step 1: Check if SSH service is running

First, log in to the server via console or out-of-band management (iLO, DRAC, IPMI). Then run:

sudo systemctl status sshd

If it says Active: active (running), great. If it's dead or failed, start it with:

sudo systemctl start sshd
sudo systemctl enable sshd

Step 2: Check firewall rules

On Ubuntu with UFW:

sudo ufw status

If you see Status: active and no rule for port 22, add it:

sudo ufw allow 22/tcp
sudo ufw reload

On CentOS/RHEL with firewalld:

sudo firewall-cmd --list-all

Look for ports: 22/tcp or services: ssh. If missing:

sudo firewall-cmd --add-service=ssh --permanent
sudo firewall-cmd --reload

Step 3: Verify SSH listens on the right interface

Your SSH config might only bind to a specific IP. Check:

sudo grep -i listen /etc/ssh/sshd_config

If you see ListenAddress 127.0.0.1, change it to ListenAddress 0.0.0.0 (or your server's actual IP). Then restart SSH:

sudo systemctl restart sshd

Step 4: Test from the client side

From your local machine, run the SSH command with verbose output:

ssh -vvv user@server-ip

Look for the line Connection established vs no route to host vs Connection timed out. If you see Connection timed out after the verbose output, the problem is definitely between your client and the server's firewall or network.

Step 5: Check network path

Ping the server:

ping -c 4 server-ip

If ping works but SSH doesn't, the firewall is almost certainly blocking port 22. If ping times out too, the server is unreachable — check your network cables, switch ports, or that the server has the right default gateway.

Still Failing? Check This

If you've done all the above and it still times out, check:

  • Cloud provider security groups: On AWS, Azure, or GCP, you must open port 22 in the security group or network ACL. I always forget this on a new instance.
  • ISP or corporate firewall: Some networks block outbound SSH. Try from a different network (like your phone hotspot) to test.
  • SSH key issues: Not the cause of timeout, but if you get past timeout to "Permission denied", that's a different error. Fix keys then.
  • Fail2ban: If you've misconfigured fail2ban, it might have banned your own IP. Check sudo fail2ban-client status sshd and unban if needed.

One last thing: I once spent an hour troubleshooting a timeout, only to realize I was SSHing into the wrong IP — I'd swapped two VMs. Double-check your ~/.ssh/config or hosts file. Happens to the best of us.

Was this solution helpful?