I am connecting to my PostgreSQL database via PHP using a Public IP (IPv4) provided in EC2 instance. The PHP is running but it does not let me create a connection with the database.
postgresql.conf:
listen_addresses = '*'
pg_hba.conf:
# IPv4 local connections:
host all all 0.0.0.0/0 trust
# IPv6 local connections:
host all all ::/0 trust
php file:
$host = "host = IPREMOVED ";
$port = "port = 5432";
$dbname = "dbname = dbName";
$credentials = "user = CREDENTIALREMOVED password = CREDENTIALREMOVED";
$response = array();
$db = pg_connect("$host $port $dbname $credentials");
if(!$db){
echo "Connection Not established\n";
}
else{
echo "sample code";
pg_close($db);
}