Connecting to postgres from windows to virtual machine
When you connect to the PostgreSQL instance via the forwarded port in the VM you're not really connecting to localhost, the port is being forwarded to the actual IP of the virtual network interface. You need to modify pg_hba.con to allow connections from IP addresses other than 127.0.0.1 for this to work.

To open up to everything add the following to pg_hba.conf. You can optionally  restrict the address to your local machine's IP address (or a subset of it):

# TYPE  DATABASE        USER            ADDRESS                 METHOD
host    all             all             all                     md5


Once it's updated restart the server or send the master process a SIGHUP so it reloads the pg_hba.conf file.



FYI, you can verify that this is what happening by creating a "server" using nc and trying to connect to it from your local machine.

On the VM forward the port 12345 to your local machine and try the following. Note that the "Connection from ..." output will come after you do the next step. See how it's not 127.0.0.1:

your-pgvm$ nc -v -l 12345
Connection from 10.0.2.2 port 12345 accepted


On your Windows machine:

your-comp$ nc localhost 12345