0

I know there are a lot of similar questions on this site, but so far I've been unable to find any answers. I have a postgres 13 server running on a WSL distro, ubuntu 20.04. I am trying to connect a gui to the server. I've tried Postbird and pgAdmin 4, both give me a similar error:

'Unable to connect to server:

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?'

Steps I have tried:

  • I can connect to the server inside of ubuntu by running psql.
  • I have changed the postgresql.conf file to include listen_addresses = '*'
  • I have modified the pg_hba.conf file to look like: pg_hba.conf
  • I have confirmed that the server is indeed running on port 5432.

Thanks for reading. Any advice would be greatly appreciated.

Jamie Kichuk
  • 1
  • 1
  • 1
  • pgAdmin is running in the Windows host? At a guess you have to find what IP the WSL distro is listening on. From the looks of it that is not `localhost`. – Adrian Klaver Jul 06 '21 at 21:10
  • @AdrianKlaver Thanks for your reply! pgAdmin is running on the windows host. Could you elaborate on what you mean? I used `netstat -ano | findstr 5432` in cmd to check if the server was running there, and indeed it was. – Jamie Kichuk Jul 06 '21 at 22:29
  • The `5432` is not the problem it is the IP address/interface the Postgres server in the WSL guest is listening on. – Adrian Klaver Jul 07 '21 at 00:12

1 Answers1

0

Ok! So my issue was indeed the pg_hba.conf file. I had to add a line at the bottom

host all all 0.0.0.0/0 trust

Once I did that, I restarted my server and was able to connect.

Jamie Kichuk
  • 1
  • 1
  • 1