我正在尝试将一个webapp推送到Heroku上,并且在让Postgres接受TCP/IP连接方面遇到了问题。我已经查阅了关于此主题的所有问题/答案,但仍然无法解决这个问题。我是数据库/ web开发的新手,非常感谢任何帮助!
在postgresql.conf中,我将侦听地址变量从localhost更改为#listen_addresses = '*'。端口看起来正确:#port = 5432。
我还将0.0.0.0添加到pg_hba.conf中(这是正确的顺序吗?)。
当我尝试启动
我能够通过另一个数据库连接到
Heroku 日志仍显示我在更改 Postgres 配置文件之前遇到的相同问题。
当我访问http://localhost:5432/时,页面显示“无数据接收”,并显示错误信息“由于服务器未发送任何数据,无法加载网页。”。
感谢您的帮助!
版本信息:Mac OSX 10.10.5、PostgreSQL 9.4.4、Heroku 3.41.5、Gradle 2.5、Java 1.8.0_51。所有这些都是使用Homebrew安装的。
在postgresql.conf中,我将侦听地址变量从localhost更改为#listen_addresses = '*'。端口看起来正确:#port = 5432。
我还将0.0.0.0添加到pg_hba.conf中(这是正确的顺序吗?)。
# TYPE DATABASE USER ADDRESS METHOD
local all all trust
host all all 0.0.0.0/0 md5
host all all 127.0.0.1/32 trust
host all all ::1/128 trust
添加了该地址后,在终端中调用postgres
,它运行了但出现了致命错误:
LOG: database system was shut down at 2015-09-06 16:21:43 PDT
LOG: MultiXact member wraparound protections are now enabled
LOG: database system is ready to accept connections
LOG: autovacuum launcher started
FATAL: database "admin" does not exist
当我尝试启动
psql
时,出现相同的消息:psql: FATAL: database "admin" does not exist
我能够通过另一个数据库连接到
psql
并创建了一个新的管理员数据库。然后我创建了我需要的应用程序数据库,并通过 Gradle 运行我的项目以确保其功能正常。在此过程中,我多次完全停止了服务器以查看更改是否有效。Heroku 日志仍显示我在更改 Postgres 配置文件之前遇到的相同问题。
Caused by: org.postgresql.util.PSQLException: Connection to
localhost:5432 refused. Check that the hostname and port are correct
and that the postmaster is accepting TCP/IP connections.
当我访问http://localhost:5432/时,页面显示“无数据接收”,并显示错误信息“由于服务器未发送任何数据,无法加载网页。”。
感谢您的帮助!
版本信息:Mac OSX 10.10.5、PostgreSQL 9.4.4、Heroku 3.41.5、Gradle 2.5、Java 1.8.0_51。所有这些都是使用Homebrew安装的。
listen_addresses
并指定值。 2)在进行pg_hba.conf
/postgresql.conf
更改后,应重新加载postgres配置,可以通过重启服务或在psql中运行pg_reload_conf()
来实现。 3)您的问题中没有指示应用程序的连接属性,请尝试检查它们,可以通过运行psql -U yourAppUser -d yourDatabase -h hostnameAddressOrDNS
来检查。 - Dmitry S