In a local network, the No Route to Host error generally occurs due to ARP resolution failure. Without the destination host’s Layer 2 address, the data packets can’t be forwarded, which leads to this error.
In the case of a remote host, users encounter this error due to an offline or non-responding host, permissions/firewall issue, or in some rare cases, DNS resolution.
We’ve detailed the probable causes and ways to resolve this error in both scenarios in this article.
How to Fix No Route To Host
We recommend starting with basic troubleshooting steps like checking the status of the host server.
Check Host Status
It may seem obvious, but you should first ping the remote host and make sure it’s actually online.
If you can ping the IP but not the hostname, the error is most likely due to a DNS issue. In such cases, use
sudo nano /etc/systemd/resolved.conf and change the DNS address.
If you have access to the host, run the
sudo systemctl status command and make sure the relevant service is actually running.
Assuming the host is online and the service is running, the error is most likely due to permission issues. First, check
/etc/hosts.deny. If there’s no issue with these config files, it’s best to troubleshoot firewall issues, as shown below.
Before fiddling with the firewall, it’s worth confirming that you’re actually trying to connect to the correct port with
sudo nmap -sS .
Assuming the port is correct, we recommend using iptables to edit the firewall rules. The commands shown below allow the specified port through the firewall and save the changes in
sudo iptables -I INPUT 6 -m state – state NEW -p tcp – dport
sudo netfilter-persistent save
Create Ingress Rule
In the case of Virtual Cloud Networks (VCN), you’ll have to add an ingress rule to your subnet to make your VM accessible from the internet. When creating the rule, use the following values:
Source CIDR: 0.0.0.0/0
IP Protocol: TCP
Destination Port Range: 80
Check Routing Table
You may also be encountering this error due to issues with the host’s routing table. You can use
netstat -rn to display the routing table and check if anything is off. For instance, one user found that one of the entries was incorrect.
/etc/network/interfaces, he found that one of the interfaces had two IP addresses, but they were both public-facing. Adding the correct netmask to one of the addresses resolved the routing issue.