Daniel Demonceau
Daniel Demonceau

Reputation: 188

Can't connect to postgreSQL in VM (Ubuntu): Access to database denied

I use a Windows 10 machine with Virtualbox 5.0.16 in which Ubuntu 15.10 is running. The network adapter is a Bridged one with the name set to Intel(R) Dual Band Wireless-AS 3165. The promiscuous-Mode is set to allow all VMs and the host and the underlying checkbox is checked (cable connected).

In this Ubuntu, I run a PostgreSQL 9.4.5 instance in which I configured both the postgresql.conf and pg_hba.conf files.

In the postgresql.conf file, I have well set this line:

listen_addresses = '*'

And in the pg_hba.conf, I have following lines at the bottom:

# TYPE  DATABASE        USER            ADDRESS                 METHOD
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
host all all 0.0.0.0/0 md5
host    all             all             ::1/128                 md5
host    all     all        ::/0                 md5
host    all     all        192.168.1.13                 md5
host    all     all        0.0.0.0/0                 md5

Currently, the ip address of my host machine is (ipconfig command and wireless) 192.168.1.13 and the guest machine is (ifconfig command) 192.168.1.4

When using pgadmin from the host machine to connect to the guest machine, I get following message: FATAL: no pg_hba.conf entry for host "192.168.1.13", user "postgres", database "postgres", SSL off

I tried to connect to my host to guest via ssh but I get a "Network error: Connection refused" message. Maybe this is a key insight of my issue?

The ping works in both directions.

Upvotes: 0

Views: 2971

Answers (1)

Daniel Demonceau
Daniel Demonceau

Reputation: 188

Thanks to @DanielVérité.

The command show hba_file showed me the pg_hba I was actually editing was not the right one. I edited the one in /etc/postgresql/9.4/main folder while the one used by postgreSQL is /opt/PostgreSQL/9.4/data

Upvotes: 2

Related Questions