How to connect to Heroku postgres database from local connection in php

I am trying to access my Heroku Postgres database from php code that runs locally.

pg_connect("host=myhost port=5432 dbname=mydb user=me password=*** sslmode=require options='--client_encoding=UTF8'") 

works well when the code runs on Heroku, but not locally. (value is the value given to Geroku)

I get this error:

Unable to connect to PostgreSQL server: sslmode "required" value is incorrect if SSL support is not compiled in

If I remove sslmode, I get this error:

The network is unavailable. Is the server running on the host "myhost" and accepting TCP / IP connections on port 5432?

Does anyone have a key? It will help a lot!

+8
php postgresql heroku local
source share
1 answer

Heroku Postgres requires sslmode for external connections. You probably need to compile PHP with the flag --with-openssl[=dir] . See here for more information: http://www.php.net/manual/en/book.openssl.php

Can you verify that your PHP installation has opensl compiled with it? The only thing I know to check this out is the phpinfo() page and look for the --with-openssl flag.

+5
source share

All Articles