Cannot reach pg server using -h localhost - Mailing list pgsql-general

From Fritz Meissner
Subject Cannot reach pg server using -h localhost
Date
Msg-id CAGUYmUa-uas7yZXWXfnU3TuOEP0+J29b5Px+QW2mnPYFSTveZg@mail.gmail.com
Whole thread Raw
Responses Re: Cannot reach pg server using -h localhost  (Adrian Klaver <adrian.klaver@aklaver.com>)
Re: Cannot reach pg server using -h localhost  (Chris Mair <chris@1006.org>)
Re: Cannot reach pg server using -h localhost  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Hi,

From the terminal in Mac OS X Yosemite, connecting to homebrew
installed 9.4.4, I have a problem if I specify the host (I know this
comes up all the time, bear with me as I have done a fair amount of
digging already). This works:

psql -Umyuser -d mydb
sql (9.3.5)
Type "help" for help.

myuser=#

Server log shows:

[unknown] LOG:  connection received: host=[local]
myuser [local]LOG:  connection authorized: user=myuser database=myuser

So that's all good. If I use -h it doesn't work:

psql -Umyuser -d mydb -h localhost
psql: server closed the connection unexpectedly
    This probably means the server terminated abnormally
    before or while processing the request.

Server log:

[unknown] LOG:  connection received: host=::1 port=51186
(... and that's it, no connection authorized line)

I've checked the normal things people suggest, e.g. postgresql.conf:

listen_addresses = 'localhost'     # also '*', '127.0.0.1', '::1'
port = 5432

and pg_hba.conf:

# IPv4 local connections:
host    all             all             127.0.0.1/32            trust
host    all             all             localhost                  trust
# IPv6 local connections:
host    all             all             ::1/128                     trust

And psql and pg_ctl are pointing to the same installations:

~ which psql
/usr/local/bin/psql
~ ll /usr/local/bin/psql
/usr/local/bin/psql -> ../Cellar/postgresql/9.4.4/bin/psql
~ which pg_ctl
/usr/local/bin/pg_ctl
~  ll /usr/local/bin/pg_ctl
/usr/local/bin/pg_ctl -> ../Cellar/postgresql/9.4.4/bin/pg_ctl

People have suggested checking for stuff on my machine that could
close connections. The Mac OS firewall is off and so is pf (Mac OS
packet filter).

This is all after upgrading (I had the same problem with 9.3.5) and
reinstalling.

Anyone got more clues for me?

Regards,
Fritz


pgsql-general by date:

Previous
From: "Joshua D. Drake"
Date:
Subject: Re: Setting up HA postgresql
Next
From: Adrian Klaver
Date:
Subject: Re: Cannot reach pg server using -h localhost