Not able to connect to Azure Database for PostgreSQL flexible server - pg_hba.conf rejects connection for host "xx.xx.xx.xxx"

Ajay Kumar 5 Reputation points
2023-08-08T00:54:45.4966667+00:00

I wanted to create a new read-only user under Azure Database for PostgreSQL. To achieve the same, I have followed this article https://learn.microsoft.com/en-us/azure/postgresql/flexible-server/how-to-create-users. However, while I trying to test the connection I am getting the following error -

28000: pg_hba.conf rejects connection for host "xx.xx.xx.xxx", user "some_new_user", database "some_test_database", SSL on Check network connectivity setting of your Azure Postgre SQL flexible server, if Pirvate Access(VNet integration) is selected, please use SHIR to connect.

28000: pg_hba.conf rejects connection for host "xx.xx.xx.xxx", user "some_new_user", database "some_test_database", SSL on

Under the firewall rules dashboard in Postgres Flexible Server, I have allowed "Allow public access from any Azure service within Azure to this server" and for debugging I added "0.0.0.0-255.255.255.255" under the firewall rules.

Thanks for your support

Azure Database for PostgreSQL
{count} votes

3 answers

Sort by: Most helpful
  1. SSingh-MSFT 16,371 Reputation points Moderator
    2023-08-16T05:05:53.8833333+00:00

    Hi Ajay Kumar •,

    As stated by you, Under the authentication for the database you had allowed Azure active directory authentication only and that was the reason the standalone users (Postgres authentication) were not working.

    Thanks for sharing the solution adopted with the community.

    1 person found this answer helpful.
    0 comments No comments

  2. SSingh-MSFT 16,371 Reputation points Moderator
    2023-08-08T06:32:27.7633333+00:00

    Hi Ajay Kumar •,

    Welcome to Microsoft Q&A forum and thanks for using Azure Services.

    As I understand, you are getting error when connecting to Azure Database for PostgreSQL.

    Could you please confirm from where are you trying to connect to the PostgreSQL Server?

    Is it Azure Data Factory/ Web App etc?

    If ADF, please refer to the link: https://techcommunity.microsoft.com/t5/azure-database-for-postgresql/how-to-access-azure-postgresql-flex-server-from-adf-managed-vnet/ba-p/3707742

    and if Web App this should help https://stackoverflow.com/questions/66827522/unable-to-access-my-azure-for-postgresql-flexible-server-through-vnet-from-app-s

    Let us know the details so that we can further assist you. Thanks

    0 comments No comments

  3. SSingh-MSFT 16,371 Reputation points Moderator
    2023-08-10T05:50:56.8+00:00

    Hi Ajay Kumar •,

    This seems strange.

    Could you please share more details of the configuration of Azure Database for PostgreSQL. Flexible server.

    I assume all below commands are executed successfully via your preferred client tool, such as pgAdmin or psql:

    User's image

    Please let us know so that we can further investigate. Thanks for your support.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.