EDIT: I just realized this question is better for ServerFault. Instead of copying it, moderator, please move it? Thank.
I checked php-info and the Postgresql extension exists ( pg_connect()not undefined). I can also connect to postgresql using psqlon localhost (I edited the pg_hba.conf file accordingly). Here is the code that does not work:
<?php
$dbconn = pg_connect("host=localhost port=5432 dbname=mydb user=myuser password=mypass") or die('Could not connect: ' . pg_last_error());
?>
This code simply causes the browser to display the message "Could not connect:".
I checked my Apache log and here is the corresponding error message:
PHP Warning: pg_connect() [<a href='function.pg-connect'>function.pg-connect</a>]:
Unable to connect to PostgreSQL server: could not connect to server: Permission
denied\n\tIs the server running on host "localhost" and accepting\n\tTCP/IP
connections on port 5432?
How can I fix / debug this?
Edit: I am in Centos 5.4 btw.