What the message looks like
ssh: connect to host 192.168.1.50 port 22: No route to hostCommon causes
- The target host is powered off or not on the same network, so ARP resolution on the LAN fails.
- The destination IP is wrong or sits in another subnet for which no route or gateway is configured.
- A firewall on the target rejects with REJECT and "icmp-host-prohibited", which produces exactly this message.
- A VPN or VLAN link is down and the route to it is missing.
- The hostname resolves to a stale IP address where no device answers any more.
Check
- Which route would be used?
ip route get 192.168.1.50 - Does the host answer ping?
ping -c 3 192.168.1.50 - Check the ARP/neighbour entry on the LAN (FAILED or INCOMPLETE is a bad sign)
ip neigh show | grep 192.168.1.50 - Test the port directly with a short timeout
nc -vz -w 3 192.168.1.50 22
Fix
- Verify the IP address and hostname first:
getent hosts server.example.comshows what the name really resolves to. - If the host is on the same LAN, check the entry with
ip neigh showand power the machine on or check the cable or Wi-Fi. - For another subnet, check the route or default gateway:
ip route. With a VPN, bring the tunnel up again. - On the target, check the firewall and allow SSH, for example
ufw allow 22/tcporfirewall-cmd --permanent --add-service=sshfollowed byfirewall-cmd --reload. - Then connect again. If the message stays, test from a third machine on the same network to rule out a client problem.
Typical scenario
A Raspberry Pi on the home network picked up a new DHCP address after a router reboot. The laptop keeps connecting to the old IP and gets No route to host even though the Pi is running. ip neigh show lists the old address as FAILED. A look at the router's DHCP lease table or arp -a reveals the new IP, and SSH works right away.
FAQ
How is this different from "Connection timed out"?
With "No route to host" an active reply (host unreachable) came back or ARP resolution failed. With a timeout there was no reply at all, typical for a firewall using DROP.
Is the SSH server at fault?
Usually not. The error occurs before any service answers. Only once the host is reachable by ping or nc is it worth looking at sshd.
Can a firewall really cause "No route to host"?
Yes. Many default setups, such as firewalld, reject disallowed ports with REJECT and "icmp-host-prohibited". The client turns that into EHOSTUNREACH and prints this message even though the host is up.
Why does ping work but SSH does not?
Then the route is fine and the host is reachable. A firewall is probably blocking TCP 22 specifically. nc -vz host 22 shows whether you get refused, a timeout or this message.
Does using the IP instead of the hostname help?
For testing, yes: it rules out a stale DNS record. If the IP works, the problem lies in name resolution or DHCP assignment, not in the network path.