I want to connect to remote database from php
to postgres
but it could not connect and says
Warning: pg_connect() [function.pg-connect]: Unable to connect to PostgreSQL server:
could not connect to server: No route to host (0x00002751/10065) Is the server running on host "xxxxxxxxx" and accepting TCP/IP connections on port 5432? in C:\xampp\htdocs\test.php on line 4
Wrong CONN_STRING
<html>
<body>
<?php
$db = pg_connect('host=xxx.xxx.xxx.xxx port=5432 dbname=postgres user=postgres password=') or die('Wrong CONN_STRING');
if (!$db) {
echo 'error';
}else{
echo 'success';
}
?>
</body>
The same database I can access from pgadmin
client which is running over same machine where apache is running, I could not understand that pgadmin can access db but apache webserver's php could not access ? any idea ?
It was problem of SELinux Following command fixed the problem
setsebool -P httpd_can_network_connect=1