The SSH client on your machine gave up trying to establish a connection with the SSH server because it didn’t receive a timely response to its initial connection request. This is usually a network issue, but it can also be a server-side problem.

1. Network Congestion or Packet Loss

Diagnosis: Run a mtr (My Traceroute) or ping command from your client machine to the server’s IP address. Look for increasing latency or packet loss as the connection progresses through various network hops.

mtr your_server_ip
ping -c 100 your_server_ip

Fix: If significant packet loss or high latency is observed on a specific hop, the issue is likely with an intermediate router or network segment. You’ll need to contact your network administrator or ISP to investigate and resolve the problem on that segment. There’s no direct fix you can apply on your client or server for this.

Why it works: mtr and ping help identify where in the network path the communication is breaking down, allowing for targeted troubleshooting.

2. Firewall Blocking SSH Traffic

Diagnosis: Check if a firewall on your client machine, the server, or any network device in between is blocking TCP port 22 (the default SSH port). On the server, use sudo ufw status (for UFW) or sudo firewall-cmd --list-all (for firewalld). On your client, check your local firewall settings. You can also use nmap from another machine on the same network as the server to check if port 22 is open:

nmap -p 22 your_server_ip

Fix: If the firewall is blocking port 22, add a rule to allow incoming SSH traffic. For UFW (on the server):

sudo ufw allow 22/tcp
sudo ufw reload

For firewalld (on the server):

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

If a network firewall is the culprit, you’ll need to update its rules accordingly.

Why it works: Explicitly allowing traffic on the SSH port ensures that connection requests can reach the SSH server.

3. SSH Server Not Running or Misconfigured

Diagnosis: Log into the server via another method (e.g., console access, IPMI) and check the status of the SSH daemon.

sudo systemctl status sshd

Look for messages indicating it’s not running, failed to start, or is listening on an unexpected port. Also, check the SSH daemon configuration file (/etc/ssh/sshd_config) for any syntax errors or incorrect directives.

Fix: If the SSH service is not running, start it.

sudo systemctl start sshd
sudo systemctl enable sshd # To ensure it starts on boot

If there are configuration errors, correct them in /etc/ssh/sshd_config and then restart the SSH service:

sudo systemctl restart sshd

Ensure Port 22 (or your custom port) is uncommented and correctly set in sshd_config.

Why it works: The SSH daemon (sshd) is the process that listens for and handles incoming SSH connections. Ensuring it’s running and properly configured is fundamental.

4. Incorrect SSH Server Listening Address

Diagnosis: Check the sshd_config file on the server for the ListenAddress directive. If it’s set to a specific IP address, ensure it’s the correct IP address that your client is trying to connect to. If it’s commented out or set to 0.0.0.0, it should listen on all available interfaces.

grep ListenAddress /etc/ssh/sshd_config

You can also use ss -tulnp | grep 22 to see which IP addresses the SSH daemon is bound to.

Fix: If ListenAddress is set to an incorrect IP, either comment it out to listen on all interfaces or change it to the correct IP address the server should be listening on.

# Example: Listen on all interfaces
# ListenAddress 0.0.0.0
# ListenAddress ::

# Example: Listen on a specific IP
# ListenAddress 192.168.1.100

# After changing, restart sshd
sudo systemctl restart sshd

Why it works: The ListenAddress directive controls which network interfaces the SSH server binds to. If it’s bound to an IP your client can’t reach, connections will fail.

5. DNS Resolution Issues

Diagnosis: If you’re connecting using a hostname, try connecting directly using the server’s IP address. If that works, the issue is with DNS resolution. Use dig or nslookup on your client to check if the hostname resolves to the correct IP address.

dig your_server_hostname
nslookup your_server_hostname

Fix: Correct the DNS records for the hostname or update your client’s DNS server settings to point to a reliable DNS server. If you have control over the DNS, ensure the A record for the hostname is correctly pointing to the server’s IP.

Why it works: Accurate DNS resolution is crucial for translating human-readable hostnames into machine-readable IP addresses, allowing your client to find the server.

6. Server Resource Exhaustion (CPU/Memory/File Descriptors)

Diagnosis: Log into the server (if possible via another method) and check its resource utilization. High CPU, low memory, or a large number of open file descriptors can prevent new processes from starting, including the SSH daemon’s ability to accept new connections.

top -n 1 -c
free -h
cat /proc/sys/fs/file-max
cat /proc/<sshd_pid>/limits | grep "Max open files"

Look for processes consuming excessive CPU or memory, or check if the system has reached its file descriptor limit.

Fix: Identify and terminate resource-hungry processes. Increase system resources (CPU, RAM) if consistently maxed out. Adjust file descriptor limits in /etc/security/limits.conf and reload the system or relevant services. For SSH specifically, you might need to increase MaxStartups in sshd_config if it’s related to too many concurrent unauthenticated connections.

# Example: Increase max open files for all users
echo "* - nofile 65536" | sudo tee -a /etc/security/limits.conf
# Reload systemd to apply changes for system services
sudo systemctl daemon-reload
# Restart sshd
sudo systemctl restart sshd

Why it works: Sufficient system resources are required for any service to operate correctly. If the server is starved, it cannot respond to new connection requests.

7. Network Address Translation (NAT) or Port Forwarding Issues

Diagnosis: If the server is behind a NAT device or router, verify that port forwarding is correctly configured to direct incoming traffic on port 22 (or the configured SSH port) to the server’s internal IP address and SSH port. Test by trying to connect from outside your local network, if possible, or by using an online port checker tool.

Fix: Ensure the NAT device/router has a rule to forward the external SSH port to the internal IP address and port of your SSH server. For example, forwarding external TCP port 22 to internal IP 192.168.1.100 on port 22.

Why it works: NAT changes the source and destination IP addresses for packets. Correct port forwarding ensures that external connection attempts are correctly routed to the intended internal server.

The next error you’ll likely encounter after resolving connection timeouts is an Authentication failed error if your credentials are not correct.

Want structured learning?

Take the full Ssh course →