-3

I am trying to connect to different server database but I keep on getting the error message

$conn =  pg_pconnect("host=xx.xx.xxx.xxx port=5432 dbname=***** user=***** password=*****") or die ("Could Not Connect. Try again later: " . pg_last_error());

Can you please assist?

Script47
  • 14,230
  • 4
  • 45
  • 66
  • What error you found in pg_last_error() ? – Jigar Chaudhary Sep 28 '17 at 08:22
  • 3
    *Can you please assist?* - Yes, I'm sure people can assist but can you please provide the relevant errors and information. Please acquaint yourself with the [how to ask](https://stackoverflow.com/help/how-to-ask) section of SO. – Script47 Sep 28 '17 at 08:24
  • This is the error "Could Not Connect. Try again later:" – Asanda Lamba Sep 28 '17 at 08:36
  • This is the error from the log 'pg_connect(): Unable to connect to PostgreSQL server: FATAL: no pg_hba.conf entry for host "00.00.00.00", user "0000", database "P$ [Thu Sep 28 10:32:07 2017] [error] [client 00.00.00.00] PHP Warning: pg_errormessage(): No PostgreSQL link opened yet' – Asanda Lamba Sep 28 '17 at 08:48
  • @AsandaLamba check port. make sure port number is correct – Bilal Ahmed Sep 28 '17 at 08:50
  • @BilalAmhed which port? – Asanda Lamba Sep 28 '17 at 08:54
  • Connection string seems to be fine. He needs to search for pg_hba.conf errors and learn how to set it up corretly, since PostgreSQL "firewall" is refusing his connection. – Łukasz Kamiński Sep 28 '17 at 08:58

1 Answers1

0

I added this line "host all all 0.0.0.0/0 md5" in the pg_hba table and it worked. Thanks all