getaddrinfo EAI_AGAIN error when connecting to Postgres DB
Hi,
One of our team is getting the below error when their API hosted in AKS connecting to Postgres DB (Configured using Private endpoint). This error is generated at random requests, say in a day 50 requests fails due to this. I verified the internal routes and everything looks to be good. Sometimes DNS fails. Anyone has any guess about this error (Attached screenshot for info).
Azure Kubernetes Service (AKS)
Azure Database for PostgreSQL
-
Ravichandran, Gopi Krishna 161 Reputation points
2024-06-19T07:04:49.08+00:00 ConnectionError [SequelizeConnectionError]: getaddrinfo EAI_AGAIN dev-airside.postgres.database.azure
-
Anveshreddy Nimmala 3,545 Reputation points • Microsoft Vendor
2024-06-19T09:35:15.08+00:00 Hello Ravichandran, Gopi Krishna,
Welcome to microsoft Q&A, thankyou for posting your query here.
"getaddrinfo" is a function used to translate a hostname into an IP address.
"EAI_AGAIN" indicates a temporary failure to resolve the hostname.
DNS errors are suspicious. Look at any timeouts or irregularities in your internal DNS setup.
In your AKS cluster, use dig or nslookup to verify that the IP address of the Postgres endpoint resolves correctly.
For any DNS resolution issues or connectivity issues, review the pod logs.
Make sure the Postgres database instance is stable and operating as it should. Look for any errors in its logs.
to get more info and possible causes please refer this link
https://github.com/nodejs/node/issues/15780
hope this helps you.
-
Ravichandran, Gopi Krishna 161 Reputation points
2024-06-19T11:20:51.16+00:00 Thanks for checking. Postgres DB is configured with Private End point using Azure Private DNS Zones. Also, the postgres DNS is resolving from Pod level.
It looks like most of the connection works and very few connection requests fails with above error.
Does it sound like any issues with Private DNS Zones that connects the Postgres DB.
-
Anveshreddy Nimmala 3,545 Reputation points • Microsoft Vendor
2024-06-20T03:34:24.7866667+00:00 Hello Ravichandran, Gopi Krishna,
There is possibility that DNS hostname cannot be resolved to ip address.
-
Anveshreddy Nimmala 3,545 Reputation points • Microsoft Vendor
2024-06-25T03:52:57.52+00:00 Hello Ravichandran, Gopi Krishna,
We haven’t heard from you on the last response and was just checking back to see if you have a resolution yet. In case if you have any resolution please do share that same with the community as it can be helpful to others. Otherwise, will respond with more details and we will try to help
-
Ravichandran, Gopi Krishna 161 Reputation points
2024-06-25T07:20:42.5166667+00:00 There was no resolution found for this issue. DNS is resolving from pods. But the DNS fails randomly. Not sure how to proceed further on this. Please let me know if you have any other approach to fix this.
-
Anveshreddy Nimmala 3,545 Reputation points • Microsoft Vendor
2024-06-25T08:16:11.4333333+00:00 Hello Ravichandran, Gopi Krishna,
Can you provide any error messages from your API and Postgres logs during connection failures.
and configuration details of your private zone.
-
Ravichandran, Gopi Krishna 161 Reputation points
2024-06-25T08:43:41.49+00:00 Hello @Anveshreddy Nimmala
I am attaching screenshot of the error popping up from the API. image (7).png
Here is our private dns zone - dev-airside.private.postgres.database.azure.com [Private DNS Zone configured/virtual network linked to our hub VNET]
nslookup resolves to an IP
Non-authoritative answer:
Name: dev-airside.private.postgres.database.azure.com
Address: 10.X.X.4
-
Anveshreddy Nimmala 3,545 Reputation points • Microsoft Vendor
2024-06-25T09:09:24.6866667+00:00 Hello Ravichandran, Gopi Krishna,
It's possible that your application isn't set up to use the private DNS zone for DNS resolution. The application settings may need to be changed to utilize the private endpoint's FQDN in the format
{your-postgresql-server-name}.privatelink.postgres.database.azure.com
if your application connects to the database using its hostname.Your application is running on a virtual network that is set up to use the hub VNET's private DNS resolver.
https://learn.microsoft.com/en-us/azure/dns/dns-private-resolver-overview
Hope this helps you
-
Ravichandran, Gopi Krishna 161 Reputation points
2024-06-25T10:11:33.5266667+00:00 Hello @Anveshreddy Nimmala
I am wondering if Postgres DB Flexible server can have {your-postgresql-server-name}.privatelink.postgres.database.azure.com.
Are you suggesting to use private endpoint FQDN [{postgres-server-name}.private.postgres.database.azure.com] in application to connect the DB.
-
Anveshreddy Nimmala 3,545 Reputation points • Microsoft Vendor
2024-06-26T03:54:13.6633333+00:00 Hello Ravichandran, Gopi Krishna,,
yes I am suggesting to use private endpoint FQDN [{postgres-server-name}.private.postgres.database.azure.com] in application to connect the DB.
Have a check on this as well.
Check if Your application is running on a virtual network that is set up to use the hub VNET's private DNS resolver.
https://learn.microsoft.com/en-us/azure/dns/dns-private-resolver-overview
-
Ravichandran, Gopi Krishna 161 Reputation points
2024-06-26T07:03:21.46+00:00 OK. Let me ask the application team to do this change and test it. I shall come back to you again.
-
Anveshreddy Nimmala 3,545 Reputation points • Microsoft Vendor
2024-06-27T07:20:41.2133333+00:00 thankyou @Ravichandran, Gopi Krishna, we will be looking forward for the update.
-
Anveshreddy Nimmala 3,545 Reputation points • Microsoft Vendor
2024-06-28T03:54:12.0066667+00:00 Hello Ravichandran, Gopi Krishna,
We haven’t heard from you on the last response and was just checking back to see if you have a resolution yet. In case if you have any resolution please do share that same with the community as it can be helpful to others. Otherwise, will respond with more details and we will try to help
-
Ravichandran, Gopi Krishna 161 Reputation points
2024-06-28T07:59:10.9766667+00:00 I am yet to get a response from application team. May be it was not tried from their side. I will come back if the issue still persists.
-
Anveshreddy Nimmala 3,545 Reputation points • Microsoft Vendor
2024-07-01T04:34:10.57+00:00 Thanks for responding back on this, please contact us back if you need any further assistance.
Sign in to comment