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:

127.0.0.1 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?

link|improve this question

80% accept rate
feedback

2 Answers

up vote 3 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.

link|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
feedback

Add your hostname to the end of line 127.0.0.1 in /etc/hosts and try again.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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