3

I am preparing a 'Web based map' application using 'Geoserver-Openlayers-Postgis'.

I am trying to connect my Postgis database(located at 10.50.110.11 location) with the following command from 10.40.48.22 location....


$host = 'localhost/10.50.110.11'; $port = '5432'; $database = 'template_postgis_20'; $user = 'postgres'; $password = 'user';

$connectString = 'host=' . $host . ' port=' . $port . ' dbname=' . $database . ' user=' . $user . ' password=' . $password;

$link = pg_connect($connectString); if (!$link) { die('Error: Could not connect: ' . pg_last_error()); echo "Could NOT connect POSTGRES..."; }


This is yielding a blank response.

2

The command should have been:

$host = '10.50.110.11'; $port = '5432'; $database = 'template_postgis_20'; $user = 'postgres'; $password = 'user';

You also need to set your server to listen to connections from interfaces. To do this, change the listen_addresses in your postgresql.conf file from 127.0.0.1 to *.

You might also want to check your pg_hba.conf. See if it allows addresses other than localhost to connect.

Sources: StackExchange thread on Postgresql

  • @ R.K...The listen_addresses in postgresql.conf is already set as '*'... – Sandipan Saha May 10 '13 at 6:43
  • Then I guess the problem is with the value in 'host'. Updated my answer. – R.K. May 10 '13 at 6:43
2

Solved..in pg.hba conf file of both servers (in my cases *.*110.11 & ..48.22) i have specified the connection details of the opposite server. Like @ ..110.11 I have specified connection info of ..48.22

  • Please edit the question with this information. – John Powell Apr 22 '16 at 7:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.