首页 > 解决方案 > heroku pg:psql 不工作 [连接被拒绝]

问题描述

我正在使用 Postgres 数据库在 Heroku 上运行 Ruby on Rails 应用程序。我曾经能够使用heroku pg:psql命令从终端连接到我的数据库

最近,情况发生了变化。运行heroku pg:psql命令后,我收到以下错误。

--> Connecting to postgresql-perpendicular-94363
psql: could not connect to server: Connection refused
    Is the server running on host "ec2-23-23-130-158.compute-1.amazonaws.com" (23.23.130.158) and accepting
    TCP/IP connections on port 5432?

我试图在网上搜索它,但没有找到任何有用的东西。

请帮忙。谢谢

标签: ruby-on-railspostgresqlherokuheroku-postgres

解决方案


我刚刚尝试连接到您的数据库:

psql "dbname=postgresql-perpendicular-94363 host=ec2-23-23-130-158.compute-1.amazonaws.com user=test_user port=5432 sslmode=require"

我有:

psql: FATAL:  password authentication failed for user "test_user"

因为,当然我不知道你的凭据:) 但是,连接似乎有效。我想,你忘了 set sslmode。正如您在文档中看到的那样,它是必需的:

所有连接都需要 SSL:sslmode=require。

更新:

我检查了没有 的连接sslmode,并且消息不是你的:

FATAL:  no pg_hba.conf entry for host "31.42.24.63", user "test_user", database "postgresql-perpendicular-94363", SSL off

所以,我想这是你互联网连接的问题。检查你的防火墙设置。


推荐阅读