When SSH prints Connection timed out, your TCP SYN packets went out and nothing came back before the client gave up. That is not the same as Connection refused, where a machine answered and said nobody is listening. A timeout points at something that silently drops traffic: a firewall, a cloud security group, a wrong IP, a machine that is off, or a network that blocks the port.
$ ssh deploy@203.0.113.10
ssh: connect to host 203.0.113.10 port 22: Connection timed out
For the refused variant, see git SSH connection refused on port 22. The difference gives you your first clue about where to look.
Step 1: confirm it is the network, not SSH itself
Test the port without involving SSH authentication:
nc -vz -w 8 203.0.113.10 22
ssh -v -o ConnectTimeout=10 deploy@203.0.113.10
The -v output shows how far it got. If you never see Connection established, authentication is not the problem. Then check the same port from another network, such as a phone hotspot, and with the पोर्ट चेकर, which probes from the public internet. The results sort the problem quickly:
- Open from the checker, timeout from your network: your office, home router, VPN or ISP is blocking or filtering.
- Timeout from everywhere: the server, its firewall or its cloud networking is the cause.
- Works from some IPs only: an allow list or a fail2ban ban is excluding yours.
Step 2: make sure you have the right address
Instances get new public IPs after a stop and start unless you reserved one. Check the provider console for the current address, and confirm DNS points at it with the DNS चेकर. ssh -v prints the IP it resolved; compare it with what the console shows. The IP लुकअप tells you who owns an address, which helps catch a stale record that now belongs to someone else.
Step 3: check that the machine is running
A stopped, crashed or overloaded server also produces a timeout. Look at the provider's status, instance state and console output. If the box is thrashing out of memory or disk, it may accept nothing. Use the provider's web console or recovery mode to reboot it. A website hosting checker can show whether the same IP also serves a website, which tells you whether the server is alive.
Step 4: inspect the firewall layers
Work through every layer between you and sshd:
- Cloud security group or network ACL: inbound TCP 22 must be allowed from your current public IP. Find yours with What Is My IP. Home and mobile IPs change, so a rule you added last month may no longer match.
- Host firewall:
sudo ufw status verbose,sudo iptables -S INPUT, orsudo nft list ruleset. - Provider or hosting-panel firewall: some control panels have a separate switch.
- fail2ban or similar:
sudo fail2ban-client status sshdlists bans, andsudo fail2ban-client set sshd unbanip YOUR.IPremoves one.
Step 5: verify sshd is listening on the port you think
If you can reach the server through a console, check it:
sudo ss -tlnp | grep sshd
sudo systemctl status ssh # Debian/Ubuntu; "sshd" on RHEL-family systems
sudo grep -E "^(Port|ListenAddress)" /etc/ssh/sshd_config
Servers hardened by hand often use a custom port. If Port 2222 is set, connect with ssh -p 2222. Note that on systems that use systemd socket activation for ssh, the listen port can come from the socket unit rather than sshd_config. Run sudo sshd -T | grep -i ^port to see the effective value.
Step 6: rule out your own network
Some corporate and public networks block outbound port 22. Try a different network, or use a provider that offers SSH over another port or a browser-based console. For Git hosting, services typically document an alternative such as SSH over port 443; check the host's current docs for the exact hostname and port. Through a VPN, confirm the route to the server is included.
If you connect through a jump host, test each hop on its own with ssh -J jump.example.com deploy@10.0.0.5 -v.
Keep it from happening again
Reserve a static IP, keep a console login path, and monitor port 22 availability. An अपटाइम मॉनिटर with a port check alerts you when SSH stops responding before a deployment fails.
अगले कदम
- Read connection refused, timed out and reset for the differences.
- Review permission denied (publickey) once you can connect.
- Understand host key verification failures after rebuilding a server.
- Use the पोर्ट चेकर to test any port from outside.
सामान्य प्रश्न
What is the difference between timed out and refused?
Refused means the target answered with a reset, so the host is up but nothing listens on that port. Timed out means no answer came back at all, usually because a firewall drops the packets.
Why did SSH stop working after my IP changed?
If a firewall or security group only allows your old address, the new one is dropped. Update the rule with your current public IP.
Can fail2ban cause a timeout?
Yes. A ban typically drops your packets, so SSH hangs. Check the jail status and unban your address.
Should I move SSH to a different port?
It reduces log noise but is not a security control on its own. Use key-only authentication and a firewall as your real protection.
Get notified when this fix updates
Plus occasional practical tips on uptime and monitoring, nothing else. Unsubscribe anytime.
यह पेज सामान्य जानकारी है, जिसे हमारी संपादकीय टीम ने लिखा है और दस्तावेज़ीकरण बदलने पर अपडेट किया जाता है। सर्वर और प्रदाता अलग-अलग होते हैं, इसलिए बदलाव पहले सुरक्षित तरीके से जाँचें। देखें: संपादकीय नीति और अस्वीकरण.