Page 1 of 1
Error from pg_hba.conf file
Posted: Mon Oct 07, 2002 4:03 pm
by pablo
Hi there. I'm getting the following error from a PHP script which is attempting to connect to a PostgreSQL db:
Warning: pg_connect() unable to connect to PostgreSQL server: FATAL 1: No pg_hba.conf entry for host 142.207.144.126, user unbc, database unbc in /u1/trng/gateway/_upload/file_upload_test.php on line 10
However I've recreated the user in question but I still get the error. Would not the entry in pg_hba.conf be created when the user is created? Or is it done some other way?
Thanks in advance,
Pablo
Posted: Tue Oct 08, 2002 9:13 am
by nielsene
Do you have a line in your pg_hba.conf file allowing that user to connect to that database from that ip (or ip range)?
When you create a user all that happens is that the user added to PostGreSQL's internal list of users. The owner of the tables/databases will have to GRANT access to the tables within PostGreSQL. Then you can configure pg_hba.conf to allow access to the database.
Most default pg_hba.conf are set up to reject all remote access, ie only allow connections over local sockets. If you want to change this behavoir you will have to modify your pg_hba.conf file. It has numerous comments that explain exactly how to accomplish most tasks. After editting the file you should be all set. There is no need to restart the PostGreSQL backend.
Posted: Tue Oct 08, 2002 11:02 am
by pablo
Hmmm, the thing is that everything is running under Oracle's IAS so it's all local, no remote connections at all.
And my sysadmin says he's set it up such that PostgreSQL should accept all connections from the server, and he also added an entry for the IAS's IP address, but I still am unable to connect.
Here's the info from pg_hba.conf:
Code: Select all
# TYPE DATABASE IP_ADDRESS MASK AUTH_TYPE AUTH_ARGUMENT
local all trust
host all 127.0.0.1 255.255.255.255 trust
host all 142.207.144.126 255.255.255.255 trust
Any other ideas what could be causing it?
Thanks in advance,
Pablo
Posted: Tue Oct 08, 2002 11:08 am
by nielsene
Do you still get the same error? Or does it give a different message now?
Posted: Tue Oct 08, 2002 11:16 am
by pablo
Hey Eric. Thanks for the prompt reply. The error message is the same:
Warning: pg_connect() unable to connect to PostgreSQL server: FATAL 1: No pg_hba.conf entry for host 142.207.144.126, user webmstr, database unbc in /u1/trng/gateway/_upload/file_upload_test.php on line 10
So as you can see there does indeed exist a record for the IP address mentioned in the error. However, there is nothing there to do with users mentioned in the error message.
The following are the access priveliges for the db in question, as generated by \dp:
Code: Select all
Access privileges for database "unbc"
Table | Access privileges
------------------------+----------------------------
unbc_users | {=,webmstr=arwdRxt,unbc=r}
unbc_users_user_id_seq |
Thanks,
P.
Posted: Tue Oct 08, 2002 11:59 am
by nielsene
What version of PostGreSQL are you running? Apparently some newer versions require you to send a SIGHUP to the postmaster process to get it to reread the pg_hba.conf file. (or if you're on a non-production system you can just restart postmaster.)
The error you're getting has nothing to do with your permissions within the table. This is purely a pg_hba.conf problem.
Posted: Tue Oct 08, 2002 12:02 pm
by pablo
Running version 7.2
Thanks,
P.
Posted: Tue Oct 08, 2002 12:07 pm
by nielsene
7.2 will require the SIGHUP to make sure that any changes made to the pg_hba.conf file are read. Check with the administrator to see if this has been done and then try again. If the error includes "pg_hba.conf" something is still wrong with its configuration. If you get a more generic permission denied message than its problems with user/table permissioning.
Posted: Tue Oct 08, 2002 12:45 pm
by pablo
Hey Eric. I got my administrator to do what you suggested and it still didn't work!!!!!
However, when I changed the name of the server to localhost (since postgres and php are running on the same box) it worked fine!
If I put the name of the server, or the dns info, it won't connect. But with localhost it works fine.
He's looking into that but at least now I can connect. Thanks very much for your help with this. Greatly appreciated.
Thanks,
P.
Posted: Tue Oct 08, 2002 12:49 pm
by nielsene
Do you know if postmaster was started with the '-i' option, without -i only localhost is allowed to conenct. Normally it gives a different error message than what you're getting, but perhaps that's the problem.