I have an error with PostgreSQL:
SQLSTATE[08006] [7] could not connect to server: Connection refused Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432?
The following command doesn't show 5432 port is open:
sudo netstat -plunt |grep postgres
I guess that the problem is 5432 port so as I don't see it at netstat
.
How to open port for PostgreSQL?
postgresql.conf
and pg_hba.conf
files are okay (see below).postgres
server is runningpostgresql.conf
file:listen_addresses = '*'
port = 5432
pg_hba.conf
file:local all postgres md5
local all all md5
host all all 0.0.0.0/0 trust
host all all 127.0.0.1/32 trust
host all all ::1/128 trust
local replication all peer
host replication all 127.0.0.1/32 md5
host replication all ::1/128 md5
$ netstat -atu
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 localhost:6379 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:http 0.0.0.0:* LISTEN
tcp 0 0 localhost:domain 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:ssh 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:https 0.0.0.0:* LISTEN
tcp 0 0 30secondboomer.com:ssh 109-252-90-59.nat:11807 ESTABLISHED
tcp 0 0 30secondboomer.com:ssh 109-252-90-59.nat:11258 ESTABLISHED
tcp 0 0 30secondboomer.com:ssh 109-252-90-59.nat:11797 ESTABLISHED
tcp6 0 0 localhost:6379 [::]:* LISTEN
tcp6 0 0 [::]:http [::]:* LISTEN
tcp6 0 0 [::]:ssh [::]:* LISTEN
tcp6 0 0 [::]:https [::]:* LISTEN
udp 0 0 localhost:domain 0.0.0.0:*
udp 0 0 30secondboomer.c:bootpc 0.0.0.0:*
Got a similar error while settings up PostgreSQL
to work with a Python/Django
project.
stop
and restart
the server again.5432
as you suspect, you can try to start postgres
on another port say 5433
and see what happens.database server
is not running at all, this solution worked for me, after reading the official PostgreSQL-9.6.16
documentation.