Re: psql connection via localhost or 127.0.0.1

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Edoardo Panfili <edoardo(at)aspix(dot)it>, pgsql-general(at)postgresql(dot)org
Subject: Re: psql connection via localhost or 127.0.0.1
Date: 2014-11-06 14:48:37
Message-ID: 545B8A45.9090206@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 11/06/2014 06:34 AM, Edoardo Panfili wrote:
> I am using postgres 9.4beta3 (Debian jessie)
>
> this is my pg_hba.conf
> ----------------------
> local all postgres peer
> local all all md5
> host all all 127.0.0.1/32 md5
> host all all ::1/128 md5
> ----------------------
>
> but if I use psql to connect via tcp to the server (on the same machine)
> I can see two differente behaviours if I use "localhost" or "127.0.0.1"
> If I understand correctly the first two lines are useful only for Unix
> sockets and not for tcp-ip connection.
>
> ------ with localhost------------
> edoardo(at)host:~$ psql -h localhost -U postgres
> psql (9.4beta3)
> Connessione SSL (protocollo: TLSv1.2, cifrario:
> ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compressione: disattivato)
> Digita "help" per avere un aiuto.
>
> postgres=#
> ------------------------------
> no password request
>
> ------ with localhost------------
> edoardo(at)happy:~$ psql -h 127.0.0.1 -U postgres
> Inserisci la password per l'utente postgres:
> ------------------------------
> with password request.
>
> Why localhost is not an alias for 127.0.0.1 ?

See here:

http://www.postgresql.org/docs/9.3/interactive/libpq-connect.html

hostaddr

>
> I did some search on Google but with no useful results
>
> thank you
> Edoardo
>
>

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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Shaun Thomas 2014-11-06 14:55:20 Re: Performance of UPDATE SET = FROM vs UPDATE SET = (SELECT ...)
Previous Message Edoardo Panfili 2014-11-06 14:34:47 psql connection via localhost or 127.0.0.1