December 17th, 2002, 01:41 AM
pg_connect() unable to connect to PostgreSQL server
Hi all. This might seem like a php question by the title but it's answer lies within postgres.
When I try to connect I get the following error:
Warning: pg_connect() unable to connect to PostgreSQL server: Connection refused. Is the server running on localhost and accepting TCP/IP connections on port 5432?
I'm quite new to having to administer postgresql so I've no idea how to check that, and haven't been able to find anything of much use online.
Can anyone give any advice?
Thanks in advance,
December 18th, 2002, 01:20 PM
Re: pg_connect() unable to connect to PostgreSQL server
I see 3 possibilities to fix your problem :
1 - Check the postmaster is launched with the -i option. It means it can get tcp/ip connections
2 - Look into the pg_hba.conf file in the pgsql folder (/var/log/pgsql under redhat). This file manages access to the postmaster. The syntax is explained inside it.
3 - If the postmaster is on the same system as apache I think u may connect it through unix sockets, not tcp/ip. BTW, what is your connection string?
December 18th, 2002, 01:23 PM
Problem was within the pg_hba.conf file. Needed to add an entry for 127.0.0.1 and all was solved.