首页 > 代码库 > “psql: could not connect to server: Connection refused” Error when connecting to remote database
“psql: could not connect to server: Connection refused” Error when connecting to remote database
问题:
I am trying to connect to a postgres database installed in a remote server using the following command: psql -h This the error that occurs:
I already tried the following but the issue remains unresolved:
Am I missing something. Hope someone can help. postgresql ubuntu psql centos7
|
|||||||||||||
|
----------------------------------------------------------------------------
cd /etc/postgresql/9.x/main/
open file named postgresql.conf
sudo vi postgresql.conf
add this line to that file
listen_addresses = ‘*‘
then open file named pg_hba.conf
sudo vi pg_hba.conf
and add this line to that file
host all all 0.0.0.0/0 md5
It allows access to all databases for all users with an encrypted password
restart your server
sudo /etc/init.d/postgresql restart
“psql: could not connect to server: Connection refused” Error when connecting to remote database