Fix no route to host
Topic: Networking basics
Summary
No route to host means the host has no route to the destination (or the destination is down/unreachable). Check the routing table, default route, and that the destination or gateway is reachable. Use this when you get 'No route to host' or 'Network is unreachable' so you can fix routing or connectivity.
Intent: Troubleshooting
Quick answer
- On the source host: ip route; ensure there is a default route or a route that matches the destination. If the destination is on another subnet, the default route (or a specific route) must point to a gateway that can reach that subnet.
- Ping the gateway: if the gateway is unreachable, fix the local link (interface, cable, gateway down). If the gateway is reachable but the destination is not, the problem is beyond the gateway (next hop, ISP, or destination down).
- No route to host can also mean the destination host is down or its firewall is blocking ICMP and the kernel returns the error; traceroute to the destination to see where the path stops.
Prerequisites
Steps
-
Check routing table on source
ip route; ip route get DESTINATION_IP. If no route (e.g. no default and destination not on-link), add default via GATEWAY or a route to the destination network; make it persistent in netplan or NM.
-
Test gateway reachability
ping -c 2 GATEWAY_IP. If the gateway is unreachable, fix the local interface (ip addr, cable, same subnet as gateway) or the gateway itself. If the gateway is reachable, the failure is further along the path.
-
Use traceroute
traceroute DESTINATION_IP (or tracepath); see which hop is the last to respond; the next hop is where the path fails (routing, firewall, or down).
-
Consider destination and firewall
The destination host may be down or its firewall may block traffic so the source gets 'no route to host' or a timeout; from another host or network, test reachability to the destination; check destination firewall and routing.
Summary
“No route to host” means the source host has no route to the destination or the path is broken. Check the routing table and default route, verify the gateway is reachable, and use traceroute to see where the path fails. Use this when connections fail with this error so you can fix routing or path connectivity.
Prerequisites
Steps
Step 1: Check routing table on source
ip route
ip route get DESTINATION_IP
If there is no default route and the destination is not on-link, add a default route: ip route add default via GATEWAY. Make it persistent in netplan or NetworkManager.
Step 2: Test gateway reachability
ping -c 2 GATEWAY_IP
If the gateway is unreachable, fix the local interface (address, cable, same subnet as gateway) or the gateway. If the gateway is reachable, the problem is further along the path.
Step 3: Use traceroute
traceroute DESTINATION_IP
The last responding hop is as far as the path works; the next hop is where it fails (routing, firewall, or host down).
Step 4: Consider destination and firewall
The destination may be down or its firewall may block traffic so the source sees “no route to host” or a timeout. Test from another host or network; check the destination’s routing and firewall.
Verification
- The source has a valid route to the destination (ip route get succeeds); ping or connection to the destination works, or you have identified the failing hop.
Troubleshooting
No default route — Add one: ip route add default via GATEWAY; make it persistent. Ensure the gateway is on the same subnet as an interface.
Gateway unreachable — Wrong gateway IP; interface down or wrong subnet; or gateway down; fix interface or gateway.