Share via

Unable to connect to Azure PostgreSQL Flexible Server via hostname over VPN, but public IP works

Inderjit Singh 20 Reputation points
2026-02-09T13:47:42.04+00:00

Hello Team,

I’m facing an issue while connecting to Azure Database for PostgreSQL Flexible Server using the hostname (FQDN). The connection works when I use the PostgreSQL public, but fails when using the server name.

Postgres is deployed in data-spoke-vnet and VPN gateway is deployed in infra-vnet, I have already done Vnet Peering, to Test this deployed one VM in Infra-vnet which is successfully connected to Postgres.

to test it via VPN I have deployed provisioned one windows VM in different azure account and installed Azure VPN Client which is connect with Azure VPN Gateway, when I try to connect Postgres it throws error :

I also tried to ping postgres hostname it throws DNS resolution failure.

ping <PSQL-SERVER>.postgres.database.azure.com Ping request could not find host <PSQL-SERVER>.postgres.database.azure.com. Please check the name and try again.

Thanks

Azure VPN Gateway
Azure VPN Gateway

An Azure service that enables the connection of on-premises networks to Azure through site-to-site virtual private networks.

{count} votes

Answer accepted by question author
  1. Ravi Varma Mudduluru 7,990 Reputation points Microsoft External Staff Moderator
    2026-02-09T13:58:24.8433333+00:00

    Hello @Inderjit Singh,

    Thanks for reaching out to Microsoft Q&A.

    As discussed, you are trying to connect to the PostgreSQL server from on‑premises, but the connection is failing because the server is configured for private access only. In this scenario, you need to add a host entry in your local hosts file.

    Please add the required host entry to your local hosts file and then try connecting to the SQL server, it should work.

    **Reference:

    **Configure Azure VPN Client optional settings - Azure VPN Gateway | Microsoft Learn

     https://github.com/dmauser/PrivateLink/tree/master/DNS-Integration-P2S

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Q&A Assist
    2026-02-09T13:47:53.8633333+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    It seems you are experiencing a DNS resolution failure when trying to connect to your Azure Database for PostgreSQL Flexible Server using the fully qualified domain name (FQDN) over a VPN. Here are some steps you can take to troubleshoot this issue:

    1. DNS Configuration: Ensure that the DNS settings for your VPN are correctly configured to resolve the FQDN of your PostgreSQL server. You may need to use Azure's DNS servers or configure custom DNS settings that can resolve Azure services.
    2. VNet Peering: Since you have already set up VNet peering, make sure that the peering configuration allows for DNS resolution across the peered VNets. Check that both VNets are set to allow traffic between them.
    3. Firewall Rules: Verify that the firewall rules for your Azure Database for PostgreSQL allow connections from the IP address of the VPN client. You may need to add the VPN's public IP address to the firewall rules.
    4. Use FQDN: As a best practice, always use the FQDN (e.g., servername.postgres.database.azure.com) instead of the IP address when connecting to Azure services, as the IP address may change.
    5. Testing Connectivity: You can also test connectivity using tools like nslookup or dig to see if the DNS resolution works from your VPN-connected VM. This can help identify if the issue is with DNS resolution or something else.

    If the issue persists after checking these configurations, consider reviewing the Azure VPN Gateway settings and ensuring that it is properly configured to allow traffic to your PostgreSQL server.


    References:

    0 comments No comments

Your answer

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