Cannot connect to Azure DB for PostgresSQL flexible from different vnet

Wilde, Andrew 0 Reputation points
2024-07-09T15:20:24.6333333+00:00

Hi, we cannot connect from an AKS pod running in one VNET to an Azure DB for PostgreSQL flexible server running in a different VNET. We can connect from an AKS pod running in the same VNET. The error is demonstrated by running curl from the pod:

curl -v redactedname.postgres.database.azure.com:5432*
** Trying 10.77.0.212:5432...*
** connect to 10.77.0.212 port 5432 failed: Connection timed out*

We have configured private access to the Azure Database for PostgreSQL flexible server according to the documentation https://learn.microsoft.com/en-us/azure/postgresql/flexible-server/concepts-networking-private#virtual-network-concepts. Our setup is similar to that shown in diagram (attached) from the article, where the green arrow shows a successful connection from an AKS cluster in the same VNET, whereas the red arrow shows unsuccessful (timed out) connection from AKS cluster in another VNET. The VNETs are peered using a hub and spoke model and we know this is working for other use-cases between the same VNETs, so we do not think this is the problem.  The private access to the Flexible Server has been configured according to the documentation link above:

  • Delegated subnet
  • Subnet configured with CIDR range of /28 to give 16 IP addresses.
  • There are no Route Tables associated to the subnet.
  • HA is not configured
  • The Network Security Group associated to subnet has been configured to allow inbound traffic on from AKS cluster  to the server on port 5432

The problem seem to be when the request reaches the subnet of the PostgreSQL server (or the server itself) since the flow logs of the NSG associated to subnet show initial connections being established, but without packets being sent:

"rule": "UserRule_postgres_allow",

                        "flows": [

                            {

                                "mac": "6045BDF210A3",

                                "flowTuples": [

                                    "1718283991,10.76.0.180,10.77.0.212,57622,5432,T,I,A,B,,,,",

                                    "1718284008,10.76.0.180,10.77.0.212,32802,5432,T,I,A,B,,,,",

                                    "1718284041,10.76.0.180,10.77.0.212,36740,5432,T,I,A,B,,,,"

                                ]

                            }

                        ]

                    }

Any help with this would be greatly appreciated.

Thanks,

Andy.

Azure Virtual Network
Azure Virtual Network
An Azure networking service that is used to provision private networks and optionally to connect to on-premises datacenters.
2,309 questions
Azure Database for PostgreSQL
{count} votes