Thread: Ident authentication failed for user
Hi: I cannot connect to my Postgres database from my PHP scripts. I get the error: PHP Warning: pg_connect(): Unable to connect to PostgreSQL server: FATAL: Ident authentication failed for user "postgres" in ... I have tried many combinations for "host" TYPE in "pg_hba.conf" (restarting postmaster) without success: # TYPE DATABASE USER CIDR-ADDRESS METHOD # "local" is for Unix domain socket connections only local all all ident # IPv4 local connections: #20120301 rbz [1291-1292] #host all all 127.0.0.1/32 ident # IPv6 local connections: #20120301 rbz [1291-1292] #host all all ::1/128 ident #20120301 rbz [1291-1292] #host all all 127.0.0.1/32 trust #host all all 0.0.0.0/0 trust #host all all * trust host all all 127.0.0.1 255.255.255.255 trust #host all all localhost trust host all all ::1/128 trust Isn't the las record the less restrictive configuration for "host" connections? I can connect to psql witout any problem. Thanks in advance for any help.
On 03/01/12 9:02 AM, Ruben Blanco wrote: > I cannot connect to my Postgres database from my PHP scripts. I get the error: > > PHP Warning: pg_connect(): Unable to connect to PostgreSQL server: > FATAL: Ident authentication failed for user "postgres" in ... > > > I have tried many combinations for "host" TYPE in "pg_hba.conf" > (restarting postmaster) without success: > > # TYPE DATABASE USER CIDR-ADDRESS METHOD > > # "local" is for Unix domain socket connections only > local all all ident > > ... > #host all all * trust > host all all 127.0.0.1 255.255.255.255 trust > #host all all localhost trust > host all all ::1/128 trust > > > Isn't the las record the less restrictive configuration for "host" connections? specify host=localhost, otherwise its using the first 'local' line, which specifies 'ident' authentication, as the error implies. you do realize, trust lets any process on the localhost authenticate as any user, including the postgres DBA account? -- john r pierce N 37, W 122 santa cruz ca mid-left coast
Hi John. Thanks a lot for your reply: El día 1 de marzo de 2012 17:25, John R Pierce <pierce@hogranch.com> escribió: > On 03/01/12 9:02 AM, Ruben Blanco wrote: > specify host=localhost, otherwise its using the first 'local' line, which > specifies 'ident' authentication, as the error implies. Where should I specify "host=localhost"? in the $connection_string for pg_connect()? It doesn't work either. I was understanding "host" TYPE was for TCP/IP connections only (my scripts run through Apache web server). That's why I didn't expect the "local" record to do anything with my connections. If I include this record in the "pg_hba.conf" file I can connect to the database: local all all trust > you do realize, trust lets any process on the localhost authenticate as any > user, including the postgres DBA account? Yes, I just want to make it run, then will tighten security measures. Thanks. > -- > john r pierce N 37, W 122 > santa cruz ca mid-left coast > > > -- > Sent via pgsql-general mailing list (pgsql-general@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-general
On 03/01/12 10:03 AM, Ruben Blanco wrote: > El día 1 de marzo de 2012 17:25, John R Pierce<pierce@hogranch.com> escribió: >> > On 03/01/12 9:02 AM, Ruben Blanco wrote: >> > specify host=localhost, otherwise its using the first 'local' line, which >> > specifies 'ident' authentication, as the error implies. > Where should I specify "host=localhost"? in the $connection_string for > pg_connect()? It doesn't work either. I don''t do much PHP, so I might have the syntax wrong, but yes.... it would go in the connection string passed to pg_Connection... however you specify a host. if you don't give a host at all, it uses the 'domain' socket, which corresponds to the LOCAL line in pg_hba.conf... if you specify host is localhost, then it uses the host .... 127.0.0.1 (or ::1) lines. -- john r pierce N 37, W 122 santa cruz ca mid-left coast