Pierre
Pierre

Reputation: 75

PostgreSQL: Access to database denied

I'm using PostgreSQL 9.1 on an Ubuntu 12.04 server. The database instance seems to run fine in general and when I try and connect from pgAdmin III via localhost on the server machine itself, there is no problem.

Whenever I try to use the LAN address 192.168.1.16 from the server, I get the error "Access to database denied."

From what I gather, the common culprit in these sorts of situations seems to be the configuration described in the pg_hba.conf file, which currently contains the following:

host all all 192.168.0.1/32 md5

As far as I understand, the instance should accept all users. Is there anything I'm missing here?

Upvotes: 1

Views: 3050

Answers (1)

Vinnix
Vinnix

Reputation: 354

Note that you are trying to connect from 192.168.1.16, however, your pg_hba.conf is allowing only 192.168.0.1 (that's what the /32 means).

Check https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing#IPv4_CIDR_blocks to learn more about CIDR notation.

If you want to allow 192.168.1.16 only you can add the following line at your pg_hba.conf:

host all all 192.168.0.16/32 md5

Then, run pg_ctl reload to apply the change made above.

This answer is assuming that you have verified the listen_address parameter in your postgresql.conf file and it's binding the correct IP values.

Upvotes: 1

Related Questions