如何修复与localhost:5432的连接被拒绝?

时间:2019-06-23 18:07:25

标签: spring postgresql digital-ocean

我有一个Digitalocean Droplet,我正在尝试安装使用postgres数据库的Java Web应用程序。我已经成功安装了Java,tomcat和postgres数据库。我可以使用pgadmin从本地机器以及本地eclipse连接到我的Droplet的postgres数据库。但是,当我在服务器上部署Web应用程序时,出现以下错误:

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.

我已将listen_addresses = '*'添加到postgresql.conf

这是pg_hba.conf中的代码

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     md5
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5
host all all 0.0.0.0/0 md5

是否存在防火墙问题?我用来连接的端口是5432。我尚未对该端口进行任何更改。

0 个答案:

没有答案
相关问题