If you’re using Rackspace Servers to create Ubuntu VPSs then you may be experiencing problems starting services.
I spent a day and a half trying to figure out why PostgreSQL wasn’t starting on my fresh Ubuntu 9.10 server (so fresh that “aptitude install postgresql-8.4” was the first command I ran).
What happened
Turns out, /etc/hosts was 0600 (only readable by root), and that was preventing PostgreSQL from starting. It would complain about not being able to create a socket bound to “localhost”. This seemed silly, since I could ping localhost just fine (as root, that is, see below).
The fun part, was that I could create another server at Rackspace with Ubuntu 9.10 and it would start right away.
The difficult part was tracking down why it worked on one machine and not the other
How to fix it
Simply chmod go+r /etc/hosts and you should be fine
Why it worked sometimes
It turns out that PostgreSQL was able to start up on servers where the UNIX hostname was NOT set to a fully qualified domain name (FQDN). So, if your hostname was “server” it would work.
However, if your hostname was “server.domain.com” it wouldn’t work.
With a non-readable /etc/hosts, any request to resolve localhost would go through DNS, and when you have a FQDN, the system must use your dnsdomainname as your default search domain. That is, when you request a hostname without a domain name, it appends your default search domain, so a request for localhost turns into localhost.domain.com which obviously doesn’t work.
If you just had a plain hostname (i.e. one without any dots in it), then a request to the DNS server for “localhost” returns 127.0.0.1 and everything works out.
Conclusion
What a pain. And the worst part is I can’t think of a good reason why /etc/hosts isn’t readable by everyone.
Also, Rackspace’s live chat support is really bad. The live chat person linked me to their wiki for Ubuntu, and asked if that was all. It’s best to open a ticket.
Blogsplat