Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

I have a problem with sudo. Every time when I trying to use sudo I got this problem:

sudo: unable to resolve host ubuntu-server

My /etc/hosts file:       localhost       ubuntu-server

# The following lines are desirable for IPv6 capable hosts

::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
FF02::2 ip6-allrouters

/etc/hostname gives:


I think there is some other setting that causes the unable to resole host, but I cannot find these.

share|improve this question

marked as duplicate by Eric Carvalho, Ravan, Pilot6, David Foerster, hg8 Jan 2 at 12:42

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Compare content of your /etc/hostname with the second line of /etc/hosts. Are there any special characters not printed out? – user279434 May 8 '14 at 14:13

Edit the /etc/hosts, you have a typo is not loopback, change it to, save and reboot.

share|improve this answer
This is the default configuration with Vagrant precise32. It uses on that line... are you sure this is wrong? It was working fine until I tried changing my hostname away from the default. – mpen Mar 1 '14 at 2:42
-1 This answer is incorrect. kind of explains this. is a common placeholder for when you don't want to, or cannot, use They both ultimately resolve to the local loopback interface (as does anything in the reserved netblock). – tripleee Jul 25 '14 at 4:21

This may mean your DNS lookups are broken.

Your /etc/hosts file looks fine. You want it too look like this:       localhost       ubuntu-server

But there are several legitimate variants.

Make sure you have a matching hostname in /etc/hostname .

Check /etc/resolv.conf to see if you have working name servers defined.

See if you can resolve any hostnames. Does nslookup work ? If not, your DNS lookup is failing, either due to configuration or a network or firewall problem (possibly at a point beyond what you have control of with your server).

In my experience, sudo will eventually ask you for you password, and grant you elevated privileges, after domain lookup times out.

Try manually adding the correct DNS name servers to /etc/resolv.conf.

In a pinch, you can use public servers. Here's what the file looks like using Google DNS servers:

/etc# cat resolv.conf
nameserver 2001:4860:4860::8888
nameserver 2001:4860:4860::8844
share|improve this answer

protected by Community Jul 23 '14 at 21:47

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.