Name or service not known

From Helpful
Jump to: navigation, search
This article/section is a stub — probably a pile of half-sorted notes, is not well-checked so may have incorrect bits. (Feel free to ignore, fix, or tell me)

...an error, with an errno of -2.

A host name lookup problem, and one that can have many different causes.


Before digging in to diagnose the problem, check the same thing on a different computer. If any test fails on other computers on the same network, it's likely to be a problem external to you (e.g. DNS server or proxy failing, or such).



Possible causes / things to look at

Nonsense lookup

If a hostname lookup is being done that makes no sense, for example gethostbyname() on an URL instead of a hostname.

host can't look up itself

If one of the following fails (replacing hostx or your favorite resolving utility):

hostx localhost
hostx `hostname`

...then it's likely your /etc/hosts is broken, or possibly the hostname you have set (there are some extra details to this when you set an FQDN as your hostname).


nameserver / proxy trouble

  • If the above work but things like:
hostx google.com
hostx yourisp.com

...all fail, then it might be DNS trouble - including not having a DNS server set (in *nices, look at /etc/resolv.conf)


nsswitch

  • Another reason for things not to work -- or sometimes for them to have weird patterns of working and not working -- can be that your /etc/nsswitch.conf is malconfigured, or configured to include something that does not work consistently (see in particular its hosts: line).