WGET can't resolve host

by Maggi Trymbill   Last Updated January 12, 2018 21:00 PM

I've got 2 machines on the same sub-net running Debian 5.0. They use the same DNS (/etc/resolv.conf), they route to the same gateway (#route) and they have the same iptables settings (#iptables -L). I can ping from both of them, both to IP addresses and to host names. I can run #host www.google.com and get the same results on both of them. But the problem is that on one of them, I can't wget or curl.

So on machine 1 everything is OK, but on machine 2 (with the same settings as machine 1) I can't wget or curl.

The error I get is:

# wget google.com
--2009-10-20 16:38:36--  http://google.com/
Resolving google.com... failed: Name or service not known.
wget: unable to resolve host address `google.com'

But on machine 1 it has no problem to wget or curl and returns:

# wget google.com
--2009-10-20 16:43:55--  http://google.com/
Resolving google.com... 74.125.53.100, 74.125.45.100, 74.125.67.100
Connecting to google.com|74.125.53.100|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
...
Saving to: `index.html.3'

Etc.

I'm hoping someone here can point me in the right direction here so that I can possibly fix this issue :)



Answers 8


Could there be an invalid proxy configured on the machine with the error? Try this:

# wget --no-proxy google.com
djhowell
djhowell
October 20, 2009 17:02 PM

try

nslookup google.com

so that we see what DNS servers you are using on both boxes.

Zepplock
Zepplock
October 20, 2009 17:28 PM

The first thing to try is checking whether DNS works correctly.

# host google.com
google.com has address 74.125.67.100
google.com has address 74.125.45.100
google.com has address 74.125.53.100

If you don't get that response, check /etc/resolv.conf and find the name servers listed in that file. Can you ping each of them?

Try querying each of them individually:

# host google.com 12.34.56.78

Can you resolve another host?

David Pashley
David Pashley
October 20, 2009 17:29 PM

Check your /etc/nsswitch.conf file (or whatever the equivalent is on Debian if it's not that).

host and nslookup always do DNS lookups.

However other applications will look in NSS first for other naming systems (e.g. /etc/hosts, NIS, etc). If something else is configured but not working it could prevent the application from ever trying the DNS.

Alnitak
Alnitak
October 20, 2009 18:55 PM

Thanks for the answers you guys!

It was the nsswitch.conf file. I had setup LDAP from a tutorial that told me to use this line in hosts:

hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4

When I changed it to this:

hosts: files dns mdns4_minimal [NOTFOUND=return] mdns4

It works without a problem. So I guess the nsswitch config file was making it return null if not found in files or mdns4_minimal, right?

Thanks for your help!

Maggi Trymbill
Maggi Trymbill
October 21, 2009 13:16 PM

I had the same problem, but next to changing /etc/nsswitch.conf:

hosts: files dns mdns4_minimal [NOTFOUND=return] mdns4

I also had to change the name servers:

Change /etc/resolv.conf so it points to the google nameservers. The ones added by network manager don't work for me.

# RED 2013-03-31
nameserver 8.8.8.8
nameserver 8.8.4.4
Redsandro
Redsandro
March 31, 2013 21:38 PM

I think you cannot change /etc/resolv.conf directly.

You need to create an /etc/resolv.conf.head file to do it.

samar
samar
July 09, 2015 18:46 PM

I had the same failure while downloading Bamboo Build Server from Atlassian download page.

My Error:

[email protected]:~$ wget https://www.atlassian.com/software/bamboo/downloads/binary/atlassian-bamboo-6.3.0.tar.gz
--2018-01-12 20:57:04--  https://www.atlassian.com/software/bamboo/downloads/binary/atlassian-bamboo-6.3.0.tar.gz
Auflösen des Hostnamen »www.atlassian.com (www.atlassian.com)«... 104.192.142.43, 104.192.142.45, 104.192.142.44
Verbindungsaufbau zu www.atlassian.com (www.atlassian.com)|104.192.142.43|:443... verbunden.
HTTP-Anforderung gesendet, warte auf Antwort... 301 Moved Permanently
Platz: https://product-downloads.atlassian.com/software/bamboo/downloads/atlassian-bamboo-6.3.0.tar.gz [folge]
--2018-01-12 20:57:05--  https://product-downloads.atlassian.com/software/bamboo/downloads/atlassian-bamboo-6.3.0.tar.gz
Auflösen des Hostnamen »product-downloads.atlassian.com (product-downloads.atlassian.com)«... fehlgeschlagen: Temporärer Fehler bei der Namensauflösung.
wget: kann die Host-Adresse »product-downloads.atlassian.com« nicht auflösen

My Problem:

After some long research i found out that wget was trying to resolve the hostname with IPv6. The Problem was that i Blocked all IPv6 Traffic to the Firewall and to the Internet.

My Solution:

The Solution is really simple. Simply add -4 to the wget command:

[email protected]:~$ wget -4 https://www.atlassian.com/software/bamboo/downloads/binary/atlassian-bamboo-6.3.0.tar.gz
--2018-01-12 21:02:28--  https://www.atlassian.com/software/bamboo/downloads/binary/atlassian-bamboo-6.3.0.tar.gz
Auflösen des Hostnamen »www.atlassian.com (www.atlassian.com)«... 104.192.142.44, 104.192.142.45, 104.192.142.43
Verbindungsaufbau zu www.atlassian.com (www.atlassian.com)|104.192.142.44|:443... verbunden.
HTTP-Anforderung gesendet, warte auf Antwort... 301 Moved Permanently
Platz: https://product-downloads.atlassian.com/software/bamboo/downloads/atlassian-bamboo-6.3.0.tar.gz [folge]
--2018-01-12 21:02:28--  https://product-downloads.atlassian.com/software/bamboo/downloads/atlassian-bamboo-6.3.0.tar.gz
Auflösen des Hostnamen »product-downloads.atlassian.com (product-downloads.atlassian.com)«... 13.32.221.177
Verbindungsaufbau zu product-downloads.atlassian.com (product-downloads.atlassian.com)|13.32.221.177|:443... verbunden.
HTTP-Anforderung gesendet, warte auf Antwort... 200 OK
Länge: 256794238 (245M) [application/x-tar]
In »»atlassian-bamboo-6.3.0.tar.gz.1«« speichern.

atlassian-bamboo-6.3.0.tar.gz.1     27%[================>                                                ]  67.15M  5.13MB/s    eta 33s
StefanHeimberg
StefanHeimberg
January 12, 2018 20:06 PM

Related Questions


bind9 not resolving specific domains

Updated December 21, 2015 08:00 AM


Running Nameserver behind NAT

Updated June 18, 2017 08:00 AM

Conditional Forwarder windows 2008 server

Updated July 27, 2015 17:00 PM