I've failed to set up postgreSQL
to work with my Ruby-on-Rails
project for the past week.
I've tried to uninstall and reinstall, postgreSQL
, twice now.
But when I try to launch postgreSQL
I keep getting the error below:
could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "localhost" (::1) and
accepting TCP/IP connections on port 5432?
could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "localhost" (127.0.0.1) and
accepting TCP/IP connections on port 5432?"
I've looked at many online resources, including stackoverflow and none seem helpful.
The key parts of my pg_hba.conf
file looks like this:
# TYPE DATABASE USER ADDRESS METHOD
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
#host replication postgres 127.0.0.1/32 md5
#host replication postgres ::1/128 md5
And the key part of my postgresql.conf
file is as follows:
listen_addresses = '*' # what IP address(es) to listen on;
# comma-separated list of addresses;
# defaults to 'localhost'; use '*' for all
# (change requires restart)
port = 5432 # (change requires restart)
max_connections = 100 # (change requires restart)
#superuser_reserved_connections = 3 # (change requires restart)
#unix_socket_directories = '' # comma-separated list of directories
# (change requires restart)
#unix_socket_group = '' # (change requires restart)
#unix_socket_permissions = 0777 # begin with 0 to use octal notation
Most of the suggestions, I've seen so far, were based on those two files. (For my case, they were already configured correctly). I also tried disabling the firewall and restarting postgreSQL but it didn't help. Does anyone have any suggestions for me? Thanks!
Got the same issue while settings up PostgreSQL 9.6.16 to work with Python/Django, but this is purely a database issue.
And here is how I resolved this issue:
postgres
or the wrapper programpg_ctl
.I used the command, below, on
windows 10
.Remember, whatever comes after
-D
should be the path to where you installed PostgreSQL, to thedata
folder, which holds thepg_hba.conf
andpostgresql.conf
files.Open another
cmd
shell, and type the command below.Remember the password you entered while installing
PostgreSQL
?Enter that password when asked
Password for user postgres:
Once done, you can now go ahead to
CREATE ROLE
andCREATE DATABASE
accordingly.