Connection to host xxxxxxxxxx at port 22 connection timed out

Abstract: Resolve SSH connection timed out errors on port 22 by diagnosing firewall blocks, DNS issues, and network routing failures.

Created: 2026-10-23 by

The "Connection to host at port 22 connection timed out" error indicates that the SSH client cannot establish a TCP handshake with the remote server within the default timeout period. This is typically caused by firewall restrictions, incorrect IP configurations, or network routing issues rather than password authentication failures. Immediate troubleshooting should focus on verifying local connectivity and ensuring no intermediate firewalls are blocking port 22 traffic.

Understanding the Connection Timeout

When you attempt to connect via SSH using ssh user@host, your system sends a SYN packet to the target IP address on port 22. A successful connection requires a SYN-ACK response from the server. If this response does not arrive within a specific timeframe (usually 10-30 seconds depending on the OS), the client throws a "connection timed out" error. This differs significantly from a "Connection refused" error, which means the server is reachable but no service is listening on port 22. It also differs from an authentication failure, where the connection succeeds but the login is rejected. A timeout implies that the packets are either being dropped silently by a firewall, lost due to network congestion, or routed to a non-existent destination. Understanding this distinction is crucial because it directs your troubleshooting toward network infrastructure rather than user credentials.

Distinguishing Between Refused and Timed Out

Before diving into complex network diagnostics, verify the exact nature of the failure. If you receive "Connection refused," the issue is likely that the SSH daemon (sshd) is not running on the target machine, or it is bound to a different port. However, since you are experiencing a timeout, the network path exists but the traffic is being intercepted or blocked. Common culprits include corporate firewalls, ISP-level filtering, or misconfigured router rules.

Step-by-Step Troubleshooting Guide

Resolving this issue requires a systematic approach to isolate where the connection is breaking down. Follow these steps in order, moving from local checks to external network verification.

1. Verify Local Network Connectivity

First, ensure your local machine can reach the internet and other hosts. Open your terminal or command prompt and run a ping test against a reliable public DNS server, such as Google's 8.8.8.8.
ping 8.8.8.8
If this fails, your local network interface or router has a fundamental connectivity issue unrelated to SSH. If it succeeds, proceed to check if you can resolve the hostname correctly. Use nslookup or dig to verify that the domain name resolves to the correct IP address. Incorrect DNS resolution can lead to timeouts if the client attempts to connect to a stale or wrong IP.

2. Test Port Accessibility with Telnet or Netcat

Since SSH uses TCP port 22, you can test if the port is open without actually attempting an SSH login. This helps determine if the blockage is specific to the SSH protocol or general port access.
telnet host_ip 22
# or
nc -vz host_ip 22
If telnet connects and displays a banner (e.g., "SSH-2.0-OpenSSH"), the port is open and accessible. If it hangs and eventually times out, the port is blocked by a firewall or the service is not responding. Note that some modern systems may not have telnet installed; nc (netcat) is often available as a lighter alternative.

3. Check for Firewall Interference

Firewalls are the most common cause of port 22 timeouts. You must check two locations: your local machine’s outgoing firewall and any intermediate firewalls between you and the host. On Linux, check your local firewall rules using iptables or ufw:
sudo ufw status
# or
sudo iptables -L -n
Ensure that outgoing connections to port 22 are allowed. On Windows, check the Windows Defender Firewall settings to ensure outbound rules permit SSH traffic. If you are behind a corporate proxy or NAT device, contact your network administrator to confirm that port 22 is whitelisted. Many organizations block standard SSH ports to prevent unauthorized tunneling, requiring you to use an alternative port like 443 or 2222.

4. Verify Server-Side Configuration

If local checks pass, the issue may lie with the remote server. Ensure that the sshd service is active and listening on all interfaces (0.0.0.0) or the specific IP you are targeting. You can check this by accessing the server console directly or through another working connection method like VNC or physical access. Run the following command on the server:
sudo systemctl status sshd
sudo netstat -tlnp | grep :22
If sshd is not running, start it with sudo systemctl start sshd. If it is running but only listening on IPv6 while you are trying to connect via IPv4, you will experience a timeout. Adjust the ListenAddress directive in /etc/ssh/sshd_config accordingly.

Advanced Diagnostics

If the standard steps do not resolve the issue, deeper network analysis is required. Use traceroute (or tracert on Windows) to identify where packets are dropping.
traceroute host_ip
Look for the hop where the response stops or shows asterisks (*). This indicates the point of failure. If the trace reaches the destination IP but still times out during SSH, the problem is likely an application-layer filter or a strict stateful firewall rule on the destination host. In cloud environments (AWS, Azure, GCP), verify that the Security Group or Firewall Rule associated with the instance allows inbound traffic on port 22 from your specific IP address range. Allowing traffic from 0.0.0.0/0 is insecure; instead, specify your home or office IP. For wireless networking issues, intermittent connectivity can also manifest as timeouts. If you are on Wi-Fi, try switching to a wired Ethernet connection to rule out signal interference. Additionally, check if your ISP is implementing deep packet inspection that might be disrupting long-lived TCP connections. In rare cases, MTU (Maximum Transmission Unit) mismatches can cause silent packet drops. You can test this by pinging the host with a specific packet size:
ping -s 1472 host_ip
If large packets fail but small ones succeed, adjust the MTU on your network interface. For more insights on related networking quirks, see our guide on Troubleshooting Networking and Wireless Issues in Google Chrome, which covers similar packet fragmentation and connectivity problems.

Alternative Connection Methods

If port 22 remains inaccessible due to rigid network policies, consider using SSH over HTTPS. Some proxies allow HTTPS traffic (port 443) while blocking SSH. Tools like stunnel or configuring your SSH client to use a proxy can bypass these restrictions. Alternatively, use a reverse tunnel or a VPN service to route your traffic through an allowed channel.

Frequently Asked Questions

Why does SSH time out but ping works?

Ping uses ICMP protocol, which is often treated differently by firewalls than TCP traffic. A firewall may allow ICMP echo requests for basic diagnostics while silently dropping TCP packets on port 22 to prevent unauthorized remote access. Always verify port accessibility separately from general connectivity.

Can I change the SSH port to avoid timeouts?

Yes, you can configure the SSH server to listen on a different port, such as 2222 or 443. On the client side, you would then use ssh -p 2222 user@host. This is useful if your network blocks standard port 22 but allows other high-numbered ports for services like web traffic.

What causes random SSH timeouts on Wi-Fi?

Wi-Fi networks are prone to interference, signal loss, and roaming issues that can interrupt TCP sessions. If your device switches access points or experiences significant signal degradation, the SSH connection may drop. Switching to a wired connection or ensuring stable Wi-Fi signal strength can mitigate this.

How do I fix timeouts when connecting to a cloud server?

Cloud providers use virtual firewalls called Security Groups or Network ACLs. Ensure that your instance’s security group explicitly allows inbound TCP traffic on port 22 from your current public IP address. Incorrectly configured rules here are the most common cause of timeouts for new cloud deployments.

Is there a way to increase the SSH timeout duration?

You can modify the timeout in your SSH client configuration file (~/.ssh/config) by adding ServerAliveInterval 60 and ServerAliveCountMax 3. This sends keep-alive messages every 60 seconds, helping maintain the connection through idle periods or lenient firewalls, though it won’t fix a hard block.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More