It seems glibc 2.12.1-r1 breaks getaddrinfo() and returns v6 only.

Use instead of localhost to work around this bug (and to work
around incomplete or broken files).

Debug output showed that the linked-list returned by getaddrinfo() only
returned the v6 entry, not v6 and v4, like it should.