Thread: pg_hba.conf file

pg_hba.conf file

From
hodges@xprt.net
Date:
I am getting this error trying to connect with


Warning: pg_connect() unable to connect to PostgreSQL server: FATAL 1: No
pg_hba.conf entry for host
127.0.0.1, user apache, database tom in /var/www/html/testphp.php on line 3
connection failed!

using
<?php

if (!pg_connect("localhost","5432","tom"))
{echo "connection failed! <br>\n"; exit;}
else
{ echo "connection successful!<br>\n";}
php?>

It is RedHat 8 and apache 2.0.40

Thanks,
Tom

Re: pg_hba.conf file

From
Oliver Elphick
Date:
On Thu, 2002-12-05 at 03:29, hodges@xprt.net wrote:
> I am getting this error trying to connect with
>
>
> Warning: pg_connect() unable to connect to PostgreSQL server: FATAL 1: No
> pg_hba.conf entry for host
> 127.0.0.1, user apache, database tom in /var/www/html/testphp.php on line 3
> connection failed!

You need a line like this (for 7.2.3 and earlier):

host  all  127.0.0.1   255.255.255.255  ident sameuser

for 7.3:

host  all  all  127.0.0.1   255.255.255.255  ident sameuser


(assuming you have a database user called 'apache' and are running an
ident server on that machine; if not, you need a different
authentication method instead of 'ident sameuser'.)

You need to make sure that this comes before any other host line that
would reject the connection.

--
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight, UK                             http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C
                 ========================================
     "Go ye therefore, and teach all nations, baptizing them
      in the name of the Father, and of the Son, and of the
      Holy Ghost; Teaching them to observe all things
      whatsoever I have commanded you; and, lo, I am with
      you alway, even unto the end of the world. Amen."
            Matthew 28:19,20