Skip to content

Instantly share code, notes, and snippets.

@mhsattarian
Last active January 14, 2022 17:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mhsattarian/8c9d2656dbb2630f19f3931ca6ef4cd2 to your computer and use it in GitHub Desktop.
Save mhsattarian/8c9d2656dbb2630f19f3931ca6ef4cd2 to your computer and use it in GitHub Desktop.
Postgres + WSL connection error

check which port postgres is working on:

# check the log
tail /var/log/postgresql/postgresql-14-main.log 

# or check the cluster list
pg_lsclusters

# or check the status
pg_isready

also make it possible to connect from other hosts by setting listen_addresses = '*' in /etc/postgresql/14/main/pg_hba.conf file.

also append this line To pga_hba.conf file to allow connections from wsl network host.

I don't know why localhost and 127.0.0.1 is not enough.

host all postgres 127.0.0.1/32 md5

# restart service after this edit

these settings worked for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment