Is there anyway to connect to the Heroku postgres (Free) db instance from a locally running PHP application. I am able to get pgAdminIII successfully connected, but no luck through application connection string connecting to the same Db?
Connection
$dbconn = pg_connect("host=xxxxxx.compute-1.amazonaws.com port=5432 dbname=xxxxxxx user=xxxxxx password=xxxxxx sslmode=require options='--client_encoding=UTF8'");
Error Thrown from PHP Code:
Warning: pg_connect(): Unable to connect to PostgreSQL server: sslmode value "require" invalid when SSL support is not compiled in in
I found the following on Heroku’s site but I am hoping someone can clarify whether I’m dealing with a postgres php issue (running PHP on Apache, PHP 5.3 on Mac OS X Lion 10.7.4) or if this is just an environment restriction as indicated in Heroku’s following statement:
How do I connect to Heroku Postgres? Databases on Heroku Postgres
accept standard PostgreSQL connections. Connections can be made from
PostgreSQL client applications (such as psql, or PGAdmin), Application
Frameworks (such as Ruby-on-Rails or Django), or any other libpq
compatible client, from anywhere over SSL.Shared databases however, can only be connected to from applications
running on Heroku.
Can someone also explain why pgAdminIII is able to connect but my application cannont?
Thank you.
Further Findings:
PHPINFO->
- OpenSSL support enabled
- OpenSSL Library Version OpenSSL 0.9.8r 8 Feb
2011 -
OpenSSL Header Version OpenSSL 0.9.8r 8 Feb 2011
-
PostgreSQL Support enabled
- PostgreSQL(libpq) Version 8.2.23
- SSL support disabled
So I spoke with a representative at Heroku. They confirmed for me that it does not require any specific tier of account to connect to a Heroku Postgres database, the only stipulation is that the connection uses ssl when connecting remotely. So my issue is the result of pgsql not having ssl support in my build of php.