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.
It may seem obvious, but you should firstping the remote hostand ensure it’s actually online.
If you may ping the IP but not the hostname, the error is most likely due toa DNS issue. In such cases, usesudo nano /etc/systemd/resolved.confand change the DNS address.
If you have access to the host, run thesudo systemctl status command and ensure 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.allowand/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 withsudo 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/etc/iptables/rules.v4.
sudo iptables -I INPUT 6 -m state –state NEW -p tcp –dport -j ACCEPTsudo netfilter-persistent save
In the case of Virtual Cloud Networks (VCN), you’ll have to add an ingress rule to your subnet to make yourVM accessible from the internet.When creating the rule, utilize the following values:
You may also be encountering this error due to issues with the host’s routing table. you may usenetstat -rnto display the routing table and verify if anything is off. For instance, one user found that one of the entries was incorrect.
Upon checking/etc/network/interfaces, he found that one of the interfaces had two IP addresses, but they were both public-facing.Adding the correct netmaskto one of the addresses resolved the routing issue.