What a Timeout Tells You
When a port is closed, a server normally answers with a rejection and you see "Connection refused" (see SSH connection refused). A timeout means nothing came back. The usual causes:
- Wrong address: a typo, an old IP, or a host name that points elsewhere.
- A firewall that drops: on the server, at the provider, or in your own network.
- Server down: stopped, still booting, or with a broken network configuration.
Step 1: Check the Address
Compare the IP with the one shown in your provider's control panel. If you connect by host name, see what it resolves to:
getent hosts example.com
If the result is not your server's IP, fix the DNS record or connect by IP for now.
Step 2: Test the Port
nc -zv -w 5 your_server_ip 22
-w 5 gives up after five seconds. Test the custom port too if SSH was moved. A ping helps only partly: many servers do not answer ping, so a failed ping proves nothing by itself, but a working ping with a timed-out port points to a firewall. The nc command guide has more port tests.
Step 3: Trace the Route
mtr -rw -c 50 your_server_ip
mtr shows each router on the path and the loss at each step. Loss that starts at one hop and continues to the end shows where traffic stops. Loss at a middle hop only, with clean hops after it, is normally harmless. More tools are in Linux network commands.
Step 4: Try Another Network
Some office, hotel, and public networks block outgoing SSH or unusual ports. Try from a mobile hotspot or another server. If it works there, the block is on your network, not on the server.
Step 5: Check the Server in the Console
Open the console in your provider's control panel. If the server is stopped, start it. If it is running, log in and check:
sudo systemctl status ssh # sshd on AlmaLinux, Rocky Linux
sudo ss -ltnp | grep ssh
ip addr
ip addr should show the public IP on a network interface. A server without its address, for example after an edit to the network configuration, cannot answer at all.
Step 6: Firewalls That Drop Packets
A firewall that drops packets silently produces a timeout. ufw's default deny policy drops; firewalld on AlmaLinux and Rocky Linux rejects unmatched packets by default, which gives an immediate error such as "No route to host" instead. Check the rules:
sudo ufw status verbose # Ubuntu, Debian
sudo firewall-cmd --list-all # AlmaLinux, Rocky Linux
Allow the SSH port if it is missing. Then check the provider side: many control panels have a network firewall or security group in front of the server, with its own rules. A Fail2ban ban can also drop packets, depending on its action; sudo fail2ban-client status sshd lists banned addresses.
Slow Instead of Dead
If the TCP connection opens but ssh times out while waiting for the server's greeting (with ConnectTimeout set, ssh reports "Connection timed out during banner exchange"), the server is reachable but probably overloaded, for example out of memory. Check load and memory in the console with top before restarting anything.