背景.. PHP スクリプトから外部から heroku データベースに接続しようとしていますが、「サーバーに接続できませんでした」というエラーが表示されます。
技術.. これは、共有データベースではなく、「クレーン」生産レベルのデータベースです。共有ホスティング プラットフォームで実行されている php スクリプトから接続しようとしていますが、
ここまでの話.. 自分のローカルマシンから、postgres.heroku.com が出力する php 接続文字列に接続できます。psql文字列にも接続できるので、接続情報に問題はありません
..しかし、そのphpスクリプトを、別のホストで稼働しているphpサーバーに移動すると、「接続できませんでした」というエラーが表示されます..これらのホストは、ホストからの外部接続の作成に制限がないことを保証します側。
コード..
$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());
エラー..
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:
オプション
最初に推測されるIPアドレスのホワイトリスト登録に関するherokuのドキュメントが見つかりませんか? 他のポインタはありますか?
編集私はこのスレッドを見つけました..
localhost PHPアプリケーションからのHeroku Postgres接続..しかし、私が見ることができる限り、正しいssl設定が有効になっています。openssl と pgsql のそれぞれの phpinfo() の関連セクションを次に示します。
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