Here’s a tips to connect PostgreSQL in VirtualBox guest OS, from Windows. The article suppose host OS is Windows, but theoretically it is also the same way in other host OS.
I installed VirtualBox in Windows, and installed Ubuntu as guest os. After that, I installed PostgreSQL server into guest Ubuntu.
- Windows 10
- Ubuntu 17.10
- PostgreSQL 9.5
Guest OS was connected with NAT system, and I configured port forwarding. If you have guest os connected through NAT, it is needed to build port forwarding connecting to the guest os PostgreSQL, TCP 5432.
To connect PostgreSQL in the guest OS from the host OS, you have to change PostgreSQL configuration.
listen_addresses description. At first, it is commented out. Set
listen_addresses = '*'
/etc/postgresql/9.5/main/pg_hba.conf, host which can connect to the database is filtered.Add the following line into IPv4 section.
host all all all md5