How to Fix “No Route to Host” Connection Error on Linux

No Route To Host Feature

When you’re trying to connect to a service on Linux, “No route to host” is one of the last things you want to hear. It’s a broad message that means your computer can’t reach the target server, whether a local server daemon running on your system or a remote server that you can’t access for whatever reason. Here we show you how to fix the “no route to host” connection error in Linux.

Why Am I Getting the “No Route to Host” error?

There are many reasons why you could be getting that error. Networking in Linux is a somewhat complicated stack that’s pretty intricate, and as a result, it’s tough to determine exactly where the issue is.

Host Is Offline/Service Isn’t Running

It may 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.

No Route To Host Systemctl Status

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.

sudo systemctl status SERVICENAME

Wrong Port

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.

sudo nmap -sS your.server.ip

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.

sudo iptables -S

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.

ping -c3 your.server.ip

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.

No Route To Host Systemd Resolve

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 “/etc/systemd/resolved.conf.” In that file, uncomment the DNS line and add either the IP of your router or another known DNS server. The default fallback DNS for Systemd is Google’s DNS servers listed under FallbackDNS.


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 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 both machines can connect to each other. Check the configurations of “/etc/hosts,” “/etc/hosts.allow,” and “/etc/hosts.deny.”

No Route To Host Cat Hosts

Finally, check your server configuration. Something may be improperly configured on the server, preventing clients from connecting properly.

Hopefully, using these tips has allowed you to fix whatever issues were happening that caused the “No Route to Host” error. Meanwhile, you can learn how to control your Wi-Fi network in Linux or check if your firewall is blocking any incoming and outgoing connection.

John Perkins
John Perkins

John is a young technical professional with a passion for educating users on the best ways to use their technology. He holds technical certifications covering topics ranging from computer hardware to cybersecurity to Linux system administration.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox