Search code examples
azureazure-postgresql

Trying to add local IP to Azure PostgreSQL server but getting getaddrinfo ENOTFOUND


I'm using Azure App Service which created an Azure Database for PostgreSQL flexible server and I keep getting this error when trying to add my local IP to the firewall throught the Azure extension on VSCode: Error

This is a screenshot of the server name from the Azure portal: server name from azure portal

I tried setting the Azure portal to public through "Network Connectivity" but the option is disabled for some reason: Network Connectivity

What is my best course of action for being able to connect to my server through my client?


Solution

  • According to this, firewall rules specify allowed public IP address ranges. The firewall grants access to the server based on the originating IP address of each request. A firewall rule will be created when public access is enabled in the networking section of the database. With private access, no public endpoint is available, and only hosts located on the same network can access Azure Database for PostgreSQL - Flexible Server. Therefore, you should enable public access to the database while creating the server as shown below. However, according to this, it is not possible to change the networking option once the server is created.

    enter image description here

    Add the client IP address by creating a firewall rule as shown below:

    enter image description here

    You will then be able to connect to the database through the client successfully, as shown below:

    enter image description here