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

Step 1

Set a password for the PostgreSQL postgres user:

sudo -u postgres psql
ALTER USER postgres PASSWORD '<a password>';

Step 2

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

host    all             all             trust

Step 3

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

listen_addresses = '*'

Step 4

Restart the postgresql service

sudo service postgresql restart

An additional information:

Step 5

Assign a static IP address to the VMware Workstation guest.

Step 6

My settings in pgAdmin 4:

The result (with a Discourse database)

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