I just created a sample Postgres db on one of my computers and configured the pg_hba.conf file and postgresql.conf file to allow remote connections.
I wrote a simple java app that uses the postgre jdbc driver and could connect to the database from another machine. But when I try to run a select query using PHP, it says connection refused.
So far the PHP looks like
<?php
$host = "host=i have the host address here";
$port = "port=5432";
$dbname = "dbname=db here";
$credentials = "user=username here password=password here";
$db = pg_connect( "$host $port $dbname $credentials" );
if(!$db){
echo "Error : Unable to open database\n";
} else {
echo "Opened database successfully\n";
}
?>
And i get the message Warning: pg_connect(): Unable to connect to PostgreSQL server: could not connect to server: Connection refused Is the server running on host "host address here" and accepting TCP/IP connections on port 5432? Error : Unable to open database
I have all the credentials, i.e. host address, username, password correct as I can query the db from a java program.
Is there anything im doing wrong?