Got stuck by the error ‘wget failed no route to host’ while installing a new piece of software?
wget is a Linux command that helps to download files from the web.
Often ‘wget failed no route to host’ refers to a network connection error or unresponsive server.
At Bobcares, we receive requests to fix wget errors as part of our Service Management Services.
Today, let’s see the causes for Wget error and how our Support Engineers fix it.
What causes wget failed no route to host error?
We’ll first check on how the error appears while executing wget command. For instance, we one of our customers tried to install a software, the following error appeared.
Let’s now check the few reasons that trigger the error ‘wget failed no route to host’.
1. Server down
For any command to execute, the server must be up and running. The same goes for the wget command as well.
If the server is not responding or any other critical error in it then the wget command will display an error.
2. Port unavailability
Similarly, port unavailability can also be a reason for wget errors.
A port is a communication endpoint. Sometimes, few customization in the iptables will disable certain ports on the server. This causes errors while executing wget command.
The port number 80 is necessary for making internet communication for wget to work well. So, disabling this port ends up in an error.
3. Firewall block
Firewall block is one of the most common reasons for wget errors.
If there is any block set in the server by a firewall, then there are a lot of chances for the wget command not to work. In other words, a firewall filters most of the unwanted connections. Thus, the wget command failed to work.
4. DNS error
When the website DNS is not resolving properly, then also wget command will throw an error.
If you are trying to wget the contents from a non-resolving website, then wget cannot fetch the contents and it ends up in failure.
So it is very much important for the hostname of the website to be resolving well.
How we fix wget failed no route to host error?
We just saw the major reasons for the wget failed no route host error message to occur. Let’s now see how our Support Engineers fix the error message.
Recently, one of our customers got the below error message while trying to wget a website.
$ wget example.com --2019-06-20 00:11:26-- http://example.com/ Resolving example.com (example.com)... x.x.x.x.x Connecting to example.com (example.com)|x.x.x.x.x|:80... failed: No route to host.
Our Support Engineers started to troubleshoot by checking the server availability.
We initially executed the below command.
Here, the server was working well. So we went checking if there is any error in DNS propagation. And the DNS was also fine.
Further, we checked the server firewall to see if there is an IP block.
iptables -L INPUT -v -n | grep x.x.x.x
However, there was no block for the IP on the server.
Further, we checked for the port restrictions using :
netstat -plunt | grep 80
This confirmed that port 80 was not active in the server. So we used the below command to enable the port 80.
sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT
Finally, this fixed the error and wget started working.
[Need help in fixing the wget errors? We’ll help you.]
In short, the wget failed no route host error is mainly caused due to the firewall blockage, port restrictions or offline remote server. Today, we saw the major reasons for the wget errors and how our Support Engineers fix it.