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.