Reputation: 41
How to connect to PostgreSQL server running in WSL from pgAdmin running in Windows? If you specify localhost and port 5432, the error appears:
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?
Upvotes: 4
Views: 7345
Reputation: 187
In addition to the previous answer, you may also need to change the postgresql.conf
file to allow sql to listen on non-local port.
For that you need to edit postgresql.conf
and change listen_addresses = 'localhost'
to listen_addresses = '*'
Then restart postgresql on wsl with sudo service postgresql restart
Upvotes: 5
Reputation: 51
i got the same issue with a Ubuntu WSL2 and here is how i solved it :
ip addr
and look for the adress in eth0
section after inet
.). for me it was 172.18.117.222/20
.host all all 172.18.117.222/20 md5
172.18.117.222
instead of localhost
.Upvotes: 5