Re: Unable to start postgresql

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: John Iliffe <john(dot)iliffe(at)iliffe(dot)ca>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Unable to start postgresql
Date: 2017-03-08 20:13:29
Message-ID: 13879.1489004009@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

John Iliffe <john(dot)iliffe(at)iliffe(dot)ca> writes:
> I tried psql but it won't work, as expected, because socket 5432 is not
> available.

Actually, that's not all that expected. psql by default would try to
connect via a Unix socket, so it wouldn't matter whether or not the
postmaster had been able to open an IPv4 port. The most likely reason
for failing to connect via Unix socket is looking in the wrong directory
for the socket, viz "/tmp" vs "/var/run/postgresql", which is why Adrian
is pressing you about other Postgres installations on the machine. If
your psql session is using a Red Hat-supplied libpq.so then it will likely
look in /var/run/postgresql, whereas this stock-sources postmaster is going
to have put it in /tmp by default. (You could adjust the
unix_socket_directories parameter to fix that.) It would also help to
pay close attention to the error message psql gives when it fails to
connect.

Even if you are doing "psql -h localhost", I'm pretty sure "localhost"
will resolve as IPv6 not IPv4 (ie ::1 not 127.0.0.1) on Fedora 25 --- it
does on mine. So if the postmaster successfully opened an IPv6 port,
which I think it would do by default, then it still wouldn't matter that
the IPv4 port wasn't there; the issue should still be masked.

FWIW, this is what I see for network sockets when lsof'ing a stock
postmaster on current Fedora 25:

...
postmaste 20082 tgl 3u IPv6 37256 0t0 TCP localhost:postgres (LISTEN)
postmaste 20082 tgl 4u IPv4 37257 0t0 TCP localhost:postgres (LISTEN)
postmaste 20082 tgl 5u unix 0xffff9eb3435cfc00 0t0 37259 /tmp/.s.PGSQL.5432 type=STREAM
...

or with -n it looks like

postmaste 20082 tgl 3u IPv6 37256 0t0 TCP [::1]:postgres (LISTEN)
postmaste 20082 tgl 4u IPv4 37257 0t0 TCP 127.0.0.1:postgres (LISTEN)
postmaste 20082 tgl 5u unix 0xffff9eb3435cfc00 0t0 37259 /tmp/.s.PGSQL.5432 type=STREAM

What I am suspicious of at this point is that the root of the problem is
networking misconfiguration on your machine, such that IPv4 doesn't work
at all; given the platform's bias towards IPv6 for loopback, you might
not have noticed otherwise. You might check what results you get from
"ping ::1" vs "ping 127.0.0.1" vs "ping localhost".

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message John Iliffe 2017-03-08 21:28:00 Re: Unable to start postgresql
Previous Message Julien Rouhaud 2017-03-08 19:37:52 Re: too may LWLocks