Cannot Connect to PosgresDB Flexible Server From in Private AKS

Huynh, Huu Thang 0 Reputation points
2025-01-13T09:14:08.78+00:00

Hi all,

I am experiencing an issue with connecting to a PostgreSQL database from a private AKS cluster. The AKS and the database are located in two different virtual networks and subscriptions.

To debug the connection, I created a pod using the following command:

kubectl run -i --

However, when I try to connect to the database using common psql commands, I receive the following error:

psql: error: could not translate host name "xxxxxxxxxxxxxxxxxxx-flexible.postgres.database.azure.com" to address: Name or service not known

The connection is successful when the database is in the same virtual network as the AKS cluster. However, it fails when the database is in a different subscription.

Upon investigation, I found that running nslookup in a pod of the AKS cluster returns a result missing the IP address of the database’s private endpoint. Is this normal behavior? When I perform the same action with other databases located in the same subscription as the AKS, the IP address values are returned correctly. The only difference is that the problematic database is in a different subscription User's image

Any help with this would be greatly appreciated.

Thanks,

Thang

Azure Private Link
Azure Private Link
An Azure service that provides private connectivity from a virtual network to Azure platform as a service, customer-owned, or Microsoft partner services.
527 questions
Azure Kubernetes Service (AKS)
Azure Kubernetes Service (AKS)
An Azure service that provides serverless Kubernetes, an integrated continuous integration and continuous delivery experience, and enterprise-grade security and governance.
2,224 questions
Azure Database for PostgreSQL
{count} votes

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.