Thread: No pg_hba.conf entry ???

No pg_hba.conf entry ???

From
"Paulo Parola"
Date:
Hi,

My ISP is having many problems with PostgreSQL (version 6.3) running upon
BSD/OS 3.1 i386 (PHP version 3.0.12) so that they made available to me a new
server running FreeBSD 3.3-RELEASE i386 (PHP version 3.0.12) and a new
version of PostgreSQL (6.5.2). I have recreated the database and its tables
at the new server and have reinstalled the PHP3 pages which access this
database but I keep receiving the following message while trying to access
the PHP3 pages:

Warning: Unable to connect to PostgresSQL server: No pg_hba.conf entry for
host xxx.xxx.xxx.xxx, user my_user, database photos in
/usr/local/etc/httpd/htdocs/image_database/image_database_search_results_br.
htm on line 12
Bad connection to database!
Sorry
.

The command to connect inside the script is the following:

if ( !($pgconn = pg_connect("localhost", "5432", "", "", "photos")) )
{
  echo "Bad connection to database!<p>Sorry<p>.\n";
}
else
{
.....
 }

My 'pg_hba.conf' is located inside directory 'data' below subdirectory 'pgsql' where PostgreSQL files are located, and
containsat the moment only the following lines (the same as in the old server): 

local        all                                                           trust
host         all         127.0.0.1     255.255.255.255   trust

Why connection works for the old server and not for the new one???

TIA,
Paulo



Re: [GENERAL] No pg_hba.conf entry ???

From
Jim Mercer
Date:
On Mon, Feb 21, 2000 at 02:01:58PM -0300, Paulo Parola wrote:
> host         all         127.0.0.1     255.255.255.255   trust
>
> Why connection works for the old server and not for the new one???

i suspect you need an entry like:

host         all         xxx.xxx.xxx.xxx     255.255.255.255   trust

where xxx.xxx.xxx.xxx is the ip address of the server running the scripts.

--
[ Jim Mercer                 jim@reptiles.org              +1 416 506-0654 ]
[          Reptilian Research -- Longer Life through Colder Blood          ]
[  Don't be fooled by cheap Finnish imitations; BSD is the One True Code.  ]

Re: [GENERAL] No pg_hba.conf entry ???

From
Jim Mercer
Date:
> The command to connect inside the script is the following:
>
> if ( !($pgconn = pg_connect("localhost", "5432", "", "", "photos")) )
> {
>   echo "Bad connection to database!<p>Sorry<p>.\n";
> }
>
> My 'pg_hba.conf' is located inside directory 'data' below
>
> local        all                                         trust
> host         all         127.0.0.1     255.255.255.255   trust

hmmm, i should have looked closer than i did before replying.

if the scripts are running on the same machine as the database, then it
should work fine as above.

if the scripts are running on a different machine, then the php code needs
to be changed to use:
> if ( !($pgconn = pg_connect("xxx", "5432", "", "", "photos")) )

where xxx is the name or ip address of the database server.

the database server would need a pg_hba.conf entry like:
> host         all         xxx     255.255.255.255   trust

where xxx is the ip address of the machine running the scripts.

--
[ Jim Mercer                 jim@reptiles.org              +1 416 506-0654 ]
[          Reptilian Research -- Longer Life through Colder Blood          ]
[  Don't be fooled by cheap Finnish imitations; BSD is the One True Code.  ]

Re: No pg_hba.conf entry ???

From
"Paulo Parola"
Date:
I have altered my pg_hba.conf file to have also a line as below:

host   all   my.real.ip.address   255.255.255.255   trust

and now I can connect to the database.

The server in question is a 'shadow' server for which I still have no domain
name associated. After I finish migration my ISP will setup DNS information
for the new server to start responding for my actual domain name. Should
that be the cause of the problem?

Even for the server with no domain name associated with it, shouldn't the
line below be sufficient for connection to succeed???

host   all   127.0.0.1   255.255.255.255   trust

TIA,
Paulo


----- Original Message -----
From: Paulo Parola <pgsql@brazilinfo.com>
To: pgsql-general <pgsql-general@postgreSQL.org>
Sent: Monday, February 21, 2000 2:01 PM
Subject: No pg_hba.conf entry ???


> Hi,
>
> My ISP is having many problems with PostgreSQL (version 6.3) running upon
> BSD/OS 3.1 i386 (PHP version 3.0.12) so that they made available to me a
new
> server running FreeBSD 3.3-RELEASE i386 (PHP version 3.0.12) and a new
> version of PostgreSQL (6.5.2). I have recreated the database and its
tables
> at the new server and have reinstalled the PHP3 pages which access this
> database but I keep receiving the following message while trying to access
> the PHP3 pages:
>
> Warning: Unable to connect to PostgresSQL server: No pg_hba.conf entry for
> host xxx.xxx.xxx.xxx, user my_user, database photos in
>
/usr/local/etc/httpd/htdocs/image_database/image_database_search_results_br.
> htm on line 12
> Bad connection to database!
> Sorry
> .
>
> The command to connect inside the script is the following:
>
> if ( !($pgconn = pg_connect("localhost", "5432", "", "", "photos")) )
> {
>   echo "Bad connection to database!<p>Sorry<p>.\n";
> }
> else
>

> .....
>  }
>
> My 'pg_hba.conf' is located inside directory 'data' below subdirectory
'pgsql' where PostgreSQL files are located, and contains at the moment only
the following lines (the same as in the old server):
>
> local        all
trust
> host         all         127.0.0.1     255.255.255.255   trust
>
> Why connection works for the old server and not for the new one???
>
> TIA,
> Paulo
>
>


Re: [GENERAL] Re: No pg_hba.conf entry ???

From
Jim Mercer
Date:
On Mon, Feb 21, 2000 at 03:25:32PM -0300, Paulo Parola wrote:
> Even for the server with no domain name associated with it, shouldn't the
> line below be sufficient for connection to succeed???
>
> host   all   127.0.0.1   255.255.255.255   trust

the address 127.0.0.1 is a "special" address meaning the local machine
(aka "localhost").

the above line will only work if the database and the scripts are on the
exact same machine.

if the database and the scripts are on different machines, then the scripts
need to open the database by specifying the name or address of the database
machine, and the database machine must have a pg_hba.conf entry listing the
address of the machine running the scripts.

--
[ Jim Mercer                 jim@reptiles.org              +1 416 506-0654 ]
[          Reptilian Research -- Longer Life through Colder Blood          ]
[  Don't be fooled by cheap Finnish imitations; BSD is the One True Code.  ]