How to access from Windows a Discourse's PostgreSQL database installed to WSL?

How do I install Discourse to Ubuntu 22 in WSL for development in Windows 10?

It is similar to: How to access a PostgreSQL database in a VMware Workstation guest from a Windows host?

Step 1

How did I fix «could not change directory to “…”: Permission denied» for PostgreSQL iin Ubuntu?

Step 2

sudo -u postgres psql

Step 3

ALTER USER postgres PASSWORD '<a password>';

E.g.:

ALTER USER postgres PASSWORD '1';

2023-11-19--01-13-24

Step 4

Add the following line to the /etc/postgresql/<version>/main/pg_hba.conf file:

host    all             all             0.0.0.0/0          trust

postgresql.org/docs/9.5/static/auth-pg-hba-conf.html

Step 5

Add the following line to the /etc/postgresql/<version>/main/postgresql.conf file:

listen_addresses = '*'

Step 6

sudo service postgresql restart

Step 7

Install pgAdmin 4 to Windows.

Step 8

2023-11-19--18-44-40

Step 9

2023-11-19--18-45-42

Step 10

2023-11-19--18-46-46

Step 11

2023-11-19--18-48-34

Step 12

How do I find out the IP address of my Ubuntu in WSL?

Step 13

2023-11-19--18-55-05

Result

2023-11-19--18-56-40

How to access a PostgreSQL database in a VMware Workstation guest from a Windows host?