Geonode logo
Network errors

How to Fix EHOSTUNREACH (No Route to Host)

Learn whether the host is off, your route is blocked or a firewall rejects you, then fix that part.

Updated

TL;DR

EHOSTUNREACH means your operating system, or a router or firewall on the way, reported that the IP in the message cannot be reached, so no server program ever saw your request. Check first that the host is on and still uses that address.

What EHOSTUNREACH looks like in each client

Your own IP and port replace the examples. If connect() fails at once, Node.js appends - Local (...). curl's last line says only Couldn't connect to server; -v shows the cause.

WhereWhat you see
Node.js http, https and netError: connect EHOSTUNREACH 192.168.1.20:8080
Node.js fetch() and its causeTypeError: fetch failed ... [cause]: Error: connect EHOSTUNREACH 192.168.1.20:8080
Python requests on LinuxFailed to establish a new connection: [Errno 113] No route to host
Python on macOS (socket, urllib)OSError: [Errno 65] No route to host
curl -v on Linux (exit code 7)* connect to 192.168.1.20 port 8080 from 192.168.1.5 port 52144 failed: No route to host
OpenSSHssh: connect to host 192.168.1.20 port 22: No route to host
Chrome, direct connectionThis site can't be reached http://192.168.1.20:8080/ is unreachable. ERR_ADDRESS_UNREACHABLE

Why this happens

No working path led from your computer to that IP address.

On Linux, a host that is switched off or now has another IP causes it: nothing on your local network answers the ARP request for that address, so after about 3 seconds the system gives up.

Diagnose your EHOSTUNREACH first

Five checks, starting with one you can do from your phone.

  • Open the address on another device on that network, such as your phone; if that fails too, the cause is the host, not your computer.

  • Compare the IP in the message with your proxy's; if they match, the missing route leads to the proxy, not the site.

  • Run ip route get with that IP on Linux, or route -n get on macOS; a VPN interface listed there means the tunnel carries it.

  • On Linux, ping the host; if it answers while the port still fails, a firewall on the way rejects that port.

  • On macOS 15 or later, run the script in the Terminal app; if it connects only there, your editor lacks Local Network access.

Solutions ranked by effectiveness

Host first, then your own machine's route, then the firewall.

  1. Most common fix

    Bring the host back at its current address

    Applies when nothing on the network gets an answer from it. Power it on, then confirm its IP, because routers lease addresses for a limited time and may hand out a new one.

    1. Check that the host is powered on and joined to your network.

    2. Read its current IP on the host itself, for example with ip addr on Linux.

    3. Put that IP in your code, config file or proxy settings, then retry.

  2. Check next

    Give your app a route to the host

    Applies when only your machine fails. On a Mac, check Local Network access; on any system, check the VPN.

    1. On macOS 15 or later, open System Settings > Privacy & Security > Local Network.

    2. Turn on the app that starts your code, such as your editor, and retry.

    3. Disconnect the VPN and retry; if it then works, have its admin exclude that subnet.

  3. Site owners

    Open the port in the host's firewall

    Applies when the server runs firewalld and nobody opened the port in its zone. Open only the port your clients need.

    1. Find the zone of the server's interface with firewall-cmd --get-active-zones, often public.

    2. Run sudo firewall-cmd --zone=public --permanent --add-port=8080/tcp && sudo firewall-cmd --reload.

    3. Connect again from the client to confirm the port now opens.

Stop the EHOSTUNREACH from coming back

Habits that keep addresses fixed and routes predictable after restarts and VPN changes.

  1. Reserve the host's IP in your router's DHCP settings, so the address stays the same after every restart.

  2. On macOS, start scripts that talk to local devices from Terminal or as a launchd daemon, which macOS allows automatically.

  3. Log err.code and err.address for every failed connection, so the log shows which hop had no route.

  4. After editing firewalld rules, run firewall-cmd --list-ports to spot a missing port before clients do.

A one-line proxy testFrom a whitelisted IP, Geonode's documented curl -x check shows the IP sites see.
Try residential proxies

Related errors

Learn more

FAQ

It is the POSIX error Host is unreachable, which tools print as No route to host. The connection stopped at the network layer, before any program on that machine could accept or refuse it.

It is EHOSTUNREACH as Python shows it on Linux, where the code is 113; macOS prints [Errno 65] and Windows [WinError 10065]. Python raises a plain OSError for it, and requests reports a ConnectionError.

ECONNREFUSED means the host answered that nothing listens on the port, and ETIMEDOUT means nothing answered before the deadline. EHOSTUNREACH means your system or a router declared the host itself unreachable.

On macOS, a connection to an IPv6 address fails with EHOSTUNREACH when your network gives you no IPv6 route; Linux reports the same case as ENETUNREACH. Use the host's IPv4 address, or fix IPv6 on the network.

It is Chrome's error -109 for the same failure on a direct connection: Chromium maps EHOSTUNREACH, EHOSTDOWN and ENETUNREACH to it, shows This site can't be reached, and Puppeteer reports it as net::ERR_ADDRESS_UNREACHABLE.

Only on your own hop to it. When the proxy itself cannot reach a site, you get the proxy's HTTP error instead, such as Squid's 503 page with The system returned: (113) No route to host.

Proxy lists built to your settings

Geonode's Endpoint Generator lists ready endpoints to copy, or to download as a .txt file.