2017-01-30 71 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地址