Re: Ubuntu 10.04 - Cannot Create TCP/IP Sockets - Mailing list pgsql-admin

From Tom Lane
Subject Re: Ubuntu 10.04 - Cannot Create TCP/IP Sockets
Date
Msg-id 11068.1272983067@sss.pgh.pa.us
Whole thread Raw
In response to Re: Ubuntu 10.04 - Cannot Create TCP/IP Sockets  ("Daniel J. Summers" <daniel.lists@djs-consulting.com>)
Responses Re: Ubuntu 10.04 - Cannot Create TCP/IP Sockets  ("Daniel J. Summers" <daniel.lists@djs-consulting.com>)
Re: Ubuntu 10.04 - Cannot Create TCP/IP Sockets  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-admin
"Daniel J. Summers" <daniel.lists@djs-consulting.com> writes:
> On 05/03/2010 02:20 PM, Tom Lane wrote:
>> OK, what about 127.0.0.1?  Given that "dig localhost" returns that,
>> it *should* behave the same, but obviously something here is not
>> behaving as expected.  Also, after you start it with '*', does
>> "psql -h localhost" work?

> Yes on both accounts.  When I had 127.0.0.1 or *, it both started up,
> and psql -h localhost gave me a password prompt.

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.

I'm guessing that there's some sort of IPv4-vs-IPv6 confusion
involved here, but it's hard to say more.

We might be able to learn something if you strace the postmaster
while it's trying to start up with "localhost" as the setting.
There will be a lot of output, so send it to a file.  Look for
the bind() calls --- on my Linux box the relevant part of the
trace looks like this:

socket(PF_INET6, SOCK_STREAM, IPPROTO_IP) = 3
setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
setsockopt(3, SOL_IPV6, IPV6_V6ONLY, [1], 4) = 0
bind(3, {sa_family=AF_INET6, sin6_port=htons(5432), inet_pton(AF_INET6, "::1", &sin6_addr), sin6_flowinfo=0,
sin6_scope_id=0},28) = 0 
listen(3, 208)                          = 0
socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 4
setsockopt(4, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
bind(4, {sa_family=AF_INET, sin_port=htons(5432), sin_addr=inet_addr("127.0.0.1")}, 16) = 0
listen(4, 208)                          = 0
getppid()                               = 12399
open("/tmp/.s.PGSQL.5432.lock", O_RDWR|O_CREAT|O_EXCL, 0600) = 5
write(5, "12400\n/var/lib/pgsql/data"..., 33) = 33
close(5)                                = 0
unlink("/tmp/.s.PGSQL.5432")            = -1 ENOENT (No such file or directory)
socket(PF_FILE, SOCK_STREAM, 0)         = 5
bind(5, {sa_family=AF_FILE, path="/tmp/.s.PGSQL.5432"}, 110) = 0
chmod("/tmp/.s.PGSQL.5432", 0777)       = 0
listen(5, 208)                          = 0

which shows the postmaster opening up both IPv6 and IPv4 sockets
as well as a Unix-domain socket in /tmp.

            regards, tom lane

pgsql-admin by date:

Previous
From: Peter Sabaini
Date:
Subject: Statistics collector port / unix dom. socket?
Next
From: Tom Lane
Date:
Subject: Re: Statistics collector port / unix dom. socket?