postgresqlazurepgadminazure-postgresql

How to connect from pgadmin to postgreSQL server with private endpoint in azure?


I just want to connect from my local host machine(pgadmin) to a azure postgreSQL database with private endpoint

So I have created a postgreSQL flexible server and I have choosen for the option Public access (allowed IP addresses) and Private endpoint.

So after the database recourse was created I went to database -> Settings-> networking: add private endpoint. I filled in all the details and I choose for dynamic ip address

The crendentials of the database are:

export PGHOST=db-postgresql-internetsuite2-0-demo.postgres.database.azure.com
export PGUSER=internetsuite2admin
export PGPORT=5432
export PGDATABASE=postgres
export PGPASSWORD="{your-password}" 

and the private endpoint looks:


> Private endpoint Connection state Virtual network / subnet Connection
> name Description pren-internetsuite2-0-demo Approved
> vn-internetsuite2-0-demo/db-internetsuite2-0-demo
> pren-internetsuite2-0-demo.26981d02-8716-4e67-be8c-6b756ef5f296
> Auto-Approved

And I didn't checked the public access checkbox on the networking tab.

and by the tab settings-> connect I see this:

Pre-requisites check
The most common connection methods have one or more of the requirements listed below
Any resources that are part of the same virtual network as the private endpoint can access the server.
SSL is enforced and TLS version is 1.2.
Server is in Ready state

And from my local host machine I can ping the database with

  Pinging db-postgresql-internetsuite2-0-demo.privatelink.postgres.database.azure.com [4.184.216.110] with 32 bytes of data:
Reply from 4.184.216.110: bytes=32 time=17ms TTL=114
Reply from 4.184.216.110: bytes=32 time=17ms TTL=114
Reply from 4.184.216.110: bytes=32 time=17ms TTL=114
Reply from 4.184.216.110: bytes=32 time=17ms TTL=114

But now I want in pgadmin connect to the azure database. So I have choosen:

register --> server and have filled in all the details by tab connection.

But after I trigger the save button. I get this error:

unable to connect to server: connection to server at 'db-postgresql-internetsuite2-0-demo.postgres.database.azure.com' (4.184.2.16.110) failed: timeout expired.

Question: how to connect the azure postgreSQL database with pgadmin?


Solution

  • Following are basic areas to check if you're having connectivity issues using Private Endpoint based networking:

    -Verify IP Address Assignments: Check that the private endpoint has the correct IP address assigned and that there are no conflicts with other resources.

    -Check Network Security Groups (NSGs): Review the NSG rules for the private endpoint's subnet to ensure the necessary traffic is allowed and doesn't have conflicting rules.

    -Validate Route Table Configuration: Ensure the route tables associated with the private endpoint's subnet and the connected resources are correctly configured with the appropriate routes.

    -Use Network Monitoring and Diagnostics: Leverage Azure Network Watcher to monitor and diagnose network traffic using tools like Connection Monitor or Packet Capture.

    Refer: https://learn.microsoft.com/en-us/azure/postgresql/flexible-server/concepts-networking-private-link

    https://learn.microsoft.com/en-us/azure/private-link/troubleshoot-private-endpoint-connectivity