dsdzvprlp51692469 2013-04-10 15:10
浏览 69

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

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
  • 写回答

1条回答 默认 最新

  • douliang1900 2013-05-15 07:02
    关注

    this works locally, but not on a separate server. The error says it cannot make the connection suggesting it never completes the syn/ack handshake. Since this works from your computer we can eliminate both Heroku and PostgreSQL. The specific error and scenario suggest it is not PHP.

    So it has to be something else. The first thing I would look at are any firewalls that sit between your server and the internet. Failing that, check any settings you may have on the AWS EC instance particularly regarding iptables.

    评论

报告相同问题?

悬赏问题

  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?