I know other people have posted similar questions but none of the solutions applied here. I have installed Postgresql-9.6 under CentOS 7 on my virtual private server, and I am trying to connect to the server locally by doing:
psql -U postgres -h [ip_address]
However, I got message like:
could not connect to server: Connection refused Is the server running on [ip_address] and accepting TCP/IP connections on port 5432?.
As suggested by previous posts, I went to postgresql.conf and set:
listen_addresses = '*' port = 5432
also, I edited pg_hba.conf as follows:
# "local" is for Unix domain socket connections only local all all md5 # IPv4 local connections: host all all 0.0.0.0/0 md5 # IPv6 local connections: host all all ::/0 md5
By restart the postgresql server, and doing:
Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:5432 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:6969 0.0.0.0:* LISTEN tcp6 0 0 :::80 :::* LISTEN tcp6 0 0 :::22 :::* LISTEN tcp6 0 0 :::5432 :::* LISTEN tcp6 0 0 ::1:25 :::* LISTEN
It shows port 5432 is listening. However, I still got same error message when trying to connect to the database locally.