Can't connect to Azure Postgres flexible server IP address not found

1.6k Views Asked by At

I've created a Azure Database for PostgreSQL flexible servers inside a virtual network, with a dedicated subnet for the database set to flexible servers. I've got a Private DNS Zone as well with an A record pointing to the database and a virtual network link setup. However, I can't connect to the database by the Azure Bash terminal.

I've tried using "host .postgres.database.azure.com" and I get this response: Error message from bash terminal

Has anyone encountered this before, or potentially knows how to solve this?

This has happened after following the default steps to create the private database in the vnet.

1

There are 1 best solutions below

2
Imran On

I created Azure Database for PostgreSQL flexible servers with virtual network like below:

enter image description here

xxx.postgres.database.azure.com is an alias for xxx.privatelink.postgres.database.azure.com Host xxx.privatelink.postgres.database.azure.com not found : 3(NXDOMAIN)

This error usually occurs if the hostname for the database is not being resolved correctly. Check if you are using the correct hostname to connect to your server.

In private dns zone added A record and ensure that virtual network links is completed:

enter image description here

Now create linux virtual machine with same virtual network and Authentication type username and password and connect to hostname like below:

ssh hostname@ipadress

enter image description here

Now you need to install the postgresql-client tool to be able to connect to the server.

sudo apt-get update
sudo apt-get install postgresql-client

Connect to the server in your Azure Database for PostgreSQL flexible servers under setting, connect and use that command connect from browser or locally like below:

enter image description here

psql -h sql1.private.postgres.database.azure.com-p 5432 -U Imran123 postgres
psql --host=mydemoserver-pg.postgres.database.azure.com --port=5432 --username=myadmin --dbname=postgres --set=sslmode=require 

When I try to connect with the above command, got result successfully like below:

![enter image description here](https://i.imgur.com/inFylt3.png)