Server Fault is a question and answer site for system and network administrators. 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

I have a server on amazon which normally runs like a champ; after increasing the instance size this weekend, then decreasing it back down to its normal size, I've started to get odd errors every time I run a command under sudo. Here's an example:

sudo ps -ef
sudo: unable to resolve host domU-##-##-##-##-##-##

Where # is a number. Its important to note the command then executes as expected. I thought there might be something bound oddly in my hosts file so I had a look at that: localhost

# 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
ff02::3 ip6-allhosts

And it seems pretty normal although I don't know enough to be sure. Can anyone shed some light on this repeating error and how to go about fixing it?

share|improve this question
up vote 4 down vote accepted

Ensure that your hostname is in /etc/hostname. To see what is in there now, you can either run hostname -f or cat /etc/hostname.

When you move your EC2 instances around, you lose your hostname so it no longer matches the hostname at the time you installed Ubuntu.

share|improve this answer
Okay, the /etc/hostname file has the host in the error - so that makes sense. Can I put a generic value in there or will it need to be changed everytime I move my EC2 instance? (this has to be done weekly). – ESW Sep 26 '11 at 16:56
You should be able to set this automatically with a little script. Something like: echo 'hostname -a' > /etc/hostname in your /etc/rc.local file should set the hostname correctly at each boot. You may have to play with the syntax a bit, but that's the gist of it. – jdw Sep 27 '11 at 12:22

It seems that you are not using the correct Amazon DNS.

If your EC2 instance is in the VPC, the DNS you should use is So you have to "add two" to the last number.

Only the DNS of your VPC will respond to your local hostname ip-XXX-XXX-XXX-XXX.

From the documentation:

The string AmazonProvidedDNS maps to a DNS server running on a reserved IP address at the base of the VPC network range "plus two". For example, the DNS Server on a network is located at

share|improve this answer

I had this issue when I copied settings from one availability zone to another. The DHCP Option Set for my VPC was pointing at us-west-1 but my new VPC was in us-west-2. As a result, when the machine was started, the EC2 scripts that set up the machine were putting this into my resolv.conf file

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
search us-west-1.compute.internal

After creating a new DHCP option set with domain=us-west-2.compute.internal and applying that to my VPC, once I restarted my EC2 instance, the resolve.conf file looked like this

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
search us-west-2.compute.internal

(note the us-west-2 in the second block versus the us-west-1 in the first), and I no longer got the "unable to resolve host" error.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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