I have 5 Postgres Servers, with IP addresses let's say as A,B,C,D and E. A is the master server and remaining are the child servers which need to access A. In the postgresql.conf file of A, the listen address has been set to '*'.

Now, let's say I want B to access A remotely. For that, the pg_hba.conf file of A should contain an entry with the IP address of B (along with other necessary data), like this for example:

host all    all     IP_Address_of_B 32    md5

But, the problem which I am facing is that even if I am entering the details of any one of the child servers in the pg_hba.conf file of A, the access to A is enabled to all of the child servers. And if I remove that entry, then the access is disabled for all.

As far as I know, if the entry of B is present in the pg_hba.conf file of A, the only B must be allowed to access A, not the remaining. But, in my case, either all have the access or none.

Is their a way to enable only B (or only a selected servers, not all) to access A ?

  • 1
    Please post complete details for these 5 entries. You must have an error somewhere as this is core functionality that works. – Colin 't Hart Jan 24 at 6:17
  • 1
    Yes, please quote pg_hba.conf verbatim. – Laurenz Albe Jan 24 at 7:39
  • Perhaps what you enter as IP_Address_of_B is its external address, that is shared by B, C, D and E? – Gerard H. Pille Jan 24 at 16:37

The IP address should be followed by either a slash and a mask length (like /32) with no whitespace, or by whitespace and a netmask (like What you seem to have here is whitespace and mask length. So you get a mask length being interpreted as a netmask. I am surprised that that doesn't throw an error upon parsing, but in any event it doesn't do what you want.

|improve this answer|||||
  • PostgreSQL throws error to log when you reload server. If there is an error, PostgreSQL uses last valid pg_hba. – Yavuz Selim Feb 11 at 8:24

Not the answer you're looking for? Browse other questions tagged or ask your own question.