Background.. I'm trying to connect to my heroku database externally from a php script and I'm getting a "Could not connect to server" error
The tech.. It's a "crane" production level database, not a shared database. I'm trying to connect from a php script, running on a shared hosting platform,
The story so far.. I can connect from my local machine and php connection strings that postgres.heroku.com outputs. I can also connect with the psql string so there's nothing wrong with the connection info
.. but when I move that php script to a php server that I have up and running on another host, then i get a "could not connect" error.. Those hosts assure me that there are no restrictions on making external connections from their side.
The code..
$dbconn = pg_connect("host=ec2-54-235-162-154.compute-1.amazonaws.com port=5882 dbname=***** user=***** password=***** sslmode=require options='--client_encoding=UTF8'") or die('Could not connect: ' . pg_last_error());
The error..
Warning: pg_connect(): Unable to connect to PostgreSQL server: could not connect to server: Connection refused Is the server running on host "ec2-54-235-162-154.compute-1.amazonaws.com" and accepting TCP/IP connections on port 5882? in /usr/local/pem/vhosts/164125/webspace/httpdocs/scheduled/postgres_vr.php on line 3 Warning: pg_last_error(): No PostgreSQL link opened yet in /usr/local/pem/vhosts/164125/webspace/httpdocs/scheduled/postgres_vr.php on line 3 Could not connect:
Options
I can't find any documentation in heroku about whitelisting an IP address which would be first guess? Any other pointers?
EDIT I just found this thread, which is similar ..
Heroku Postgres Connection from localhost PHP application .. but I have the correct ssl settings enabled as far as I can see.
Here's the relevant section from the phpinfo() on the openssl and pgsql respectively..
OpenSSL support enabled
OpenSSL Library Version OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008
OpenSSL Header Version OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008
PostgreSQL(libpq) Version 8.1.23
Multibyte character support enabled
SSL support enabled
Active Persistent Links 0
Active Links 0
Directive Local Value Master Value
pgsql.allow_persistent On On
pgsql.auto_reset_persistent Off Off
pgsql.ignore_notice Off Off
pgsql.log_notice Off Off
pgsql.max_links Unlimited Unlimited
pgsql.max_persistent Unlimited Unlimited