pgAdmin 无法连接到 PostgreSQL 9.1

Nyx*_*nyx 5 postgresql ubuntu database

我正在尝试在 Windows 上使用 pgAdmin 连接到postgresql在 localhost 的 Ubuntu 12.04 VM 上运行的 9.1.8。主机的 5432 端口转发到 VM 的 5432 端口。

pgAdmin 错误:

Error connecting to the server: could not receive data from server: Software caused connection abortion (0x00002745/10053)

配置文件

#------------------------------------------------------------------------------
# CONNECTIONS AND AUTHENTICATION
#------------------------------------------------------------------------------

# - Connection Settings -

listen_addresses = '*'
port = 5432 
Run Code Online (Sandbox Code Playgroud)

pg_hba.conf

local   all             postgres                                peer

# TYPE  DATABASE        USER            ADDRESS                 METHOD

host    all             all             0.0.0.0/0               md5
host    all             all             127.0.0.1/32            md5
host    all             all             ::1/128                 md5 
Run Code Online (Sandbox Code Playgroud)

netstat -nlp | 5432

tcp        0      0 127.0.0.1:5432          0.0.0.0:*               LISTEN      29035/postgres
unix  2      [ ACC ]     STREAM     LISTENING     50823    29035/postgres      /var/run/postgresql/.s.PGSQL.5432
Run Code Online (Sandbox Code Playgroud)

iptables 规则

iptables -I INPUT -p tcp --dport 5432 -j ACCEPT
Run Code Online (Sandbox Code Playgroud)

PostgreSQL 服务已重新启动,pgAdmin 仍然给出错误。任何想法是什么导致了它?

Dan*_*ité 0

TCP 数据包允许输入,但是否允许从虚拟机到主机输出?

如果需要 INPUT 规则,则可能还需要 OUTPUT 规则,例如:

iptables -I OUTPUT -p tcp --sport 5432 -m state --state ESTABLISHED -j ACCEPT
Run Code Online (Sandbox Code Playgroud)

您也可以看看这个相关问题: Unable to connect to Postgres on Vagrant Box - Connection Beenrejected