I wrote:
> Huh. Well, there seems to be no other possible conclusion except that
> getaddrinfo() is returning something valid for "127.0.0.1" but not
> for "localhost". And it's not failing outright for "localhost", but
> returning a sockaddr that bind() won't actually accept.
For the archives: some off-list investigation revealed that Daniel's
machine is resolving "localhost" as "localhost.us", which resolves as
216.240.187.169, which of course is not a local address on his machine
so the bind() fails.
It's not immediately clear to me why his machine is resolving it like
that --- there's no search directive in /etc/resolv.conf, and even more
interestingly nslookup doesn't react that way --- but maybe Ubuntu has
some other configuration setting for DNS search path. The other
interesting question is what in the world made the owners of the .us
domain think it'd be a good idea to offer a translation of "localhost"
that's not 127.0.0.1. But anyway, this seems to be a DNS configuration
problem and not a Postgres bug.
regards, tom lane