- Download and Install binary executable [postgresql.exe] on windows (https://www.enterprisedb.com/downloads/postgres-postgresql-downloads) this will be the server for databases. Take note of the credentials for user [postgres] that you set during the installation, we will use this to connect from WSL in the end.
- Install postgresql-client and associated libraries on WSL2:
sudo apt-get update
sudo apt-get install postgresql-client postgresql-client-common libpq-dev
- Go to Windows defender firewall with Advanced Security on Windows.
- Select Inbound Rules and create a new Rule.