Let's say I have a pg_hba.conf file for my Postgresql server. I know that in order to allow other IP addresses to access my Postgresql server, I need to write their entries in my pg_hba.conf file. Now, what I don't understand is the use of the column USER in the pg_hba.conf file. Lets say my file contains the following entry

host all    user123    md5

According to my understanding, it means that in order to access my Postgresql server from the machine with IP, someone needs to be logged in as the user 'user123'. But, as far as i understand, in order to access my Postgresql server from, i need to create a separate connection to my server from So even if I am logged in as 'user123', I will be anyways creating a separate connection to access my Postgresql server, which won't depend on whether I am logged in as 'user123' or someone else. Hence, I don't understand the use of USER column. Can someone please help me?


"someone needs to be logged in as the user 'user123'" - no, that means that someone tries to connect with the Postgres database user user123.

This can be used to allow certain database users to connect only from certain client computers, e.g. the user for a web application is only allowed to connect from the IP of the webserver.

Or this can be used to prevent superuser logins from remote connections by only allowing local connections for the database user postgres.

  • Ok, so you mean, the user 'user123' needs to be present in my Postgresql server, not on – suvrat Nov 4 '19 at 13:19
  • Correct, it's a database user – a_horse_with_no_name Nov 4 '19 at 14:03
  • Thanks a lot for clearing my confusion. – suvrat Nov 4 '19 at 14:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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