使用psql遠程連接數(shù)據(jù)庫報錯:Connection refused和No route to host
1、問題現(xiàn)象
使用psql遠程連接數(shù)據(jù)庫報錯:Connection refused和No route to host。
psql: could not connect to server: Connection refused
|

psql: could not connect to server:No route to host
|
[highgo@hgdb ~]$ psql -h 192.168.10.123 -p 5866
psql: could not connect to server: No route to host
Is the server running on host "192.168.10.123" and accepting TCP/IP connections on p ort 5866?
|
2、解決方案
(1)首先確認(rèn)數(shù)據(jù)庫服務(wù)是否已經(jīng)啟動。

(2)檢查監(jiān)聽并查看IP地址是否正確。
# su - highgo $ cat $PGDATA/postgresql.conf|grep listen $ cat $PGDATA/postgresql.auto.conf |grep listen $ cat $PGDATA/postgresql.conf|grep port $ cat $PGDATA/postgresql.auto.conf |grep port
|
例如:
listen_addresses = '*'
port = 5866
|

(3)查看pg_hba.conf文件確定是否具有正確的配置。
su – highgo
cat $PGDATA/pg_hba.conf
|
例如:允許遠程主機192.168.10.123無密碼訪問數(shù)據(jù)庫的配置如下

