Skip to content

/errors/wget/unable-to-resolve-host-address

wget: unable to resolve host address

The commands on this page have not been executed by our verification runner yet.updated
tool
wget
exit code
4
versions
GNU Wget 1.x
os
linux, macos, windows

wget: unable to resolve host address 'example.org' means wget could not turn the host name in the URL into an IP address. The DNS lookup failed before any connection was attempted, so the problem is the name or the machine's DNS configuration, not the web server. Check the spelling, then test the lookup with getent hosts example.org; if that also fails, fix the network or DNS settings, or configure the proxy your network requires. wget exits with status 4 (network failure).

wget prints the host between quotes; in a UTF-8 locale they are typographic quotes (‘example.org’), in the C locale plain ones ('example.org'). Before the error, it shows Resolving example.org (example.org)... failed: ... with the resolver's own reason, such as Name or service not known or Temporary failure in name resolution.

Diagnose

bash
getent hosts example.org          # uses the same resolver as wget (nsswitch, /etc/hosts, DNS)
cat /etc/resolv.conf              # which DNS servers are configured
nslookup example.org 1.1.1.1      # does a public resolver know the name?
env | grep -i _proxy              # proxy variables wget will use
Resolver messageLikely cause
Name or service not knownThe name does not exist (typo, wrong domain, internal name outside the VPN)
Temporary failure in name resolutionNo DNS server reachable: offline, wrong resolv.conf, firewall
No address associated with hostnameThe name exists but has no A or AAAA record

Fixes

bash
# a proxy is required on this network
export https_proxy=http://proxy.example.com:3128
export http_proxy=http://proxy.example.com:3128
wget https://example.org/file.tar.gz

# Docker: give one container a DNS server
docker run --dns 1.1.1.1 --rm alpine wget -q -O- https://example.org/

On WSL, /etc/resolv.conf is generated by WSL; if it points to an unreachable server, set generateResolvConf = false under [network] in /etc/wsl.conf and write your own resolv.conf.

Sources