2017-01-30 70 views
1

我试图在Ubuntu服务器上设置PostgreSQL远程连接。Amazon EC2:PostgreSQL远程连接挂起

/etc/postgresql/9.3/main/postgresql.conf

改变listen_addresses = 'localhost'listen_addresses = '*'然后我加入到postgre配置文件/etc/postgresql/9.3/main/pg_hba.conf线

host all all 0.0.0.0/0 md5 host all all ::0/0 md5 host all all all md5

但是,当我试图通过psql -U db_user -h host -d db_name来连接远程数据库它挂起,并显示消息

psql: could not connect to server: Connection timed out Is the server running on host "host_address" and accepting TCP/IP connections on port 5432?

pgAdmin的连接挂起以及

+0

您必须在数据库服务器上运行'pg_ctl reload'才能重新加载新配置。使用数据库服务器上的'netstat -a'来检查它是否正在侦听您期望的端口。尝试使用telnet在端口5432上打开从客户端到服务器的TCP连接(或任何您配置的),以查看它是否是网络问题。 –

回答

1

使用Amazon EC2服务有同样的问题

解决方法: 1)进入安全组服务器实例 2)编辑入站规则 3)允许所有流量您的IP地址