Re: Cannot reach pg server using -h localhost

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Fritz Meissner <fritz(dot)meissner(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Cannot reach pg server using -h localhost
Date: 2015-07-21 17:30:44
Message-ID: 55AE81C4.5040801@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 07/21/2015 10:09 AM, Fritz Meissner wrote:
> 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)

So what happens if you do?:

psql -U myuser -d mydb -h 127.0.0.1

>
> 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
>
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Chris Mair 2015-07-21 17:39:09 Re: Cannot reach pg server using -h localhost
Previous Message Fritz Meissner 2015-07-21 17:09:43 Cannot reach pg server using -h localhost