How to fix "wget: unable to resolve host address" issue
If wget has a hostname resolution problem like the error below:
“wget: unable to resolve host address domain.com”
Example:
[root@ezylinux ~]# wget www.ezylinux.com
--2013-06-01 05:26:52-- http://www.ezylinux.com/
Resolving www.ezylinux.com... failed: Name or service not known.
wget: unable to resolve host address www.ezylinux.com
First, check whether the machine’s network works by using ping as shown:
[root@ezylinux ~]# ping www.ezylinux.com
PING ezylinux.com (74.53.235.34) 56(84) bytes of data.
64 bytes from ezylinux.com (74.53.235.34): icmp_seq=1 ttl=48 time=283 ms
64 bytes from ezylinux.com (74.53.235.34): icmp_seq=2 ttl=48 time=319 ms
64 bytes from ezylinux.com (74.53.235.34): icmp_seq=3 ttl=48 time=316 ms
64 bytes from ezylinux.com (74.53.235.34): icmp_seq=4 ttl=48 time=340 ms
64 bytes from ezylinux.com (74.53.235.34): icmp_seq=5 ttl=48 time=296 ms
64 bytes from ezylinux.com (74.53.235.34): icmp_seq=6 ttl=48 time=282 ms
64 bytes from ezylinux.com (74.53.235.34): icmp_seq=7 ttl=48 time=299 ms
--- ezylinux.com ping statistics ---
7 packets transmitted, 7 received, 0% packet loss, time 6888ms
rtt min/avg/max/mdev = 282.505/305.501/340.585/19.648 ms
If ping fails, the problem is with the network. If ping succeeds, wget is trying IPv6 on a machine without IPv6 in use, so it cannot work. There are several ways to fix wget: unable to resolve host address domain.com:
-
Use -4 or —inet4-only to make wget use IPv4, as shown:
[root@ezylinux ~]# wget --inet4-only www.ezylinux.comor
[root@ezylinux ~]# wget -4 www.ezylinux.com -
Map the host to its IP address in /etc/hosts, as shown:
74.53.235.34 ezylinux.com -
Edit wget’s configuration file, /etc/wgetrc, and add the following parameter:
inet4_only = on
Then try using it again. :)