Re: Please Help me with connecting my PostgreSQL - Mailing list psycopg

From Adrian Klaver
Subject Re: Please Help me with connecting my PostgreSQL
Date
Msg-id 4D94A935.1000701@gmail.com
Whole thread Raw
In response to Re: Please Help me with connecting my PostgreSQL  (Daniele Varrazzo <daniele.varrazzo@gmail.com>)
List psycopg
On 03/31/2011 07:56 AM, Daniele Varrazzo wrote:
> On Thu, Mar 31, 2011 at 3:07 PM, Adrian Klaver<adrian.klaver@gmail.com>  wrote:
>> On Thursday, March 31, 2011 6:42:35 am Daniele Varrazzo wrote:
>>
>>>
>>> To connect to a database on the local machine, the quick answer is:
>>> add host=127.0.0.1 to the connection string, which makes it connect to
>>> the network socket instead of the unix socket. And I mean "127.0.0.1",
>>> not "localhost".
>>
>> localhost works also:)
>
> Sometimes I've been bitten by a badly configured /etc/hosts and/or
> pg_hba.conf, and if localhost doesn't resolve to 127.0.0.1 in both
> directions (not granted when both IPv4 and IPv6 enabled) the
> connection will fail, or the wrong pg_hba rule may be used.

Got you, so it not that localhost is not allowed, but that an explicit
IP address eliminates a possible bug.

>
> Of course it doesn't happen on a well configured server, but because
> the OP is in "shotgun debugging" mode, as the 5433 typo shows,
> avoiding the use of a name to be solved is an element less that may
> fail.
>
> More details are in the box at
> http://developer.postgresql.org/pgdocs/postgres/auth-pg-hba-conf.html#AEN30140
>
> -- Daniele


--
Adrian Klaver
adrian.klaver@gmail.com

psycopg by date:

Previous
From: Daniele Varrazzo
Date:
Subject: Re: Please Help me with connecting my PostgreSQL
Next
From:
Date:
Subject: psycopg and the GPL