Heroku postgres ingress-无法连接到服务器错误


Heroku postgres ingress - could not connect to server error

背景我正试图从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:

选项

我在heroku中找不到任何关于将IP地址列入白名单的文档,这是第一个猜测吗?还有其他指针吗?

EDIT我刚刚找到了这个线程,它是类似的
来自localhost PHP应用程序的Heroku Postgres连接。。但据我所见,我已经启用了正确的ssl设置。以下是phpinfo((中关于openssl和pgsql的相关部分。。

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

这可以在本地工作,但不能在单独的服务器上工作。错误表明它无法建立连接,这表明它从未完成syn/ack握手。由于这在您的计算机上有效,我们可以消除Heroku和PostgreSQL。具体的错误和场景表明它不是PHP。

所以它必须是其他的东西。我首先要看的是位于服务器和互联网之间的任何防火墙。否则,请检查您在AWS EC实例上的任何设置,特别是关于iptables的设置。