When you’re trying to connect to a service on Linux, “No route to host” is one of the last things that you want to hear. It’s a broad message that means that your computer can’t reach the target server.
Because of the broad nature of the message there are several possibilities that could be causing it.
Host Is Offline/Service Isn’t Running
It might seem painfully obvious, but you should first check that the server that you’re trying to connect to is even online. It might have been taken down for maintenance or be experiencing issues.
The service itself might not have been started. If it’s your server, you can check to see if the service has been started and is running properly. To do that with Systemd, run the following command.
You may be trying to connect on the incorrect port. Many system administrators choose to run commonly targeted services like SSH on different ports to help thwart would-be attackers.
If the server isn’t your own, check the available documentation or contact their support services.
For your own server, you can try using NMAP to figure out where you started your service.
If you think you used a really obscure port, you can use the
-p- flag to scan them all. It will take a while though.
Iptables Is Blocking the Connection
You may have accidentally configured iptables to block connections on that port. You would receive the same message whether you configured iptables on the server or your desktop, so it’s worth checking both. To see your iptables rules, run the following command.
Your DNS Is Improperly Configured
If all else fails, you should try to
ping the IP address that you’re looking to connect to. It could be that your computer isn’t connecting to a DNS server properly.
If the ping works but connecting a domain name doesn’t, you’re looking at a DNS issue.
Systemd users can run
systemd-resolve --status to check the DNS servers that your system is using. It’s broken down by interface, so make sure to check the one that you’re actually trying to connect through.
In most cases your computer will discover the relevant DNS information over DHCP. If you’re using a static IP or something on your network is configured differently, you may have to set your DNS manually.
Open up “/etc/systemd/resolved.conf.” In that file uncomment the
DNS line and add in either the IP of your router or another known DNS server. The default fallback DNS for Systemd is Google’s DNS servers listed under
If you’re using OpenRC or another Systemd alternative, you can find your DNS information in “/etc/resolv.conf.”
If there’s nothing there, enter in the IP address of your router or any other known DNS server that you’d prefer to use.
After either, restart networking or your entire computer.
The GUI Way
If you’re using a graphical desktop with Network Manager, you can edit your connection information that way. Open the applet or go through your system settings. Select your connection and find the “IPv4” tab. Switch the connection to “Manual,” and manually enter in the IP address of your computer and the IP of your router as the gateway. Then, in the DNS field below, enter your router’s IP or the IP of another DNS server.
Incorrect Network or Host Configuration
There are several other configuration options that may be incorrect. Any of them would make it impossible for your computer to connect to the server.
First, make sure that your computer’s network configuration is correct. Double-check the configuration files themselves, and of course, see if you can connect to the Internet another way.
If you’re using a specific hostname to connect or you’ve set up specific hosts on either the server or the client, you need to make sure that both machines can connect to each other. Check the configurations of “/etc/hosts,” “/etc/hosts.allow.” “/etc/hosts.deny.”
Finally, check your server configuration. Something might be improperly configured on the server, preventing clients from connecting properly.
While nailing down the exact cause of “No route to host” is not that straightforward, you can follow these steps to rule out the most common causes of the error and remedy it.