๐ Resolving Azure App Service Connectivity Issues with Supabase PostgreSQL

Recently, I faced an interesting connectivity issue while deploying a .NET Core application hosted on Azure App Service, trying to connect to a Supabase PostgreSQL database. While the app worked fine locally, it failed when deployed to Azure. Here's how I identified the problem and fixed it.
๐ The Problem
My application was using this PostgreSQL connection string:
Host=
db.zovrkyywxdlnkqglddaz.supabase.co
;Port=5432;Database=postgres;Username=****;Password=****;Ssl Mode=Require;Trust Server Certificate=true
Locally, everything worked perfectly. But once deployed to Azure App Service, the application failed to connect, throwing errors such as:
No such host is known: Error Log
fail: Microsoft.EntityFrameworkCore.Database.Connection[20004] An error occurred using the connection to database 'postgres' on server 'tcp://
db.zovrkyywxdlnkqglddaz.supabase.co:5432
'.
fail: Microsoft.EntityFrameworkCore.Query[10100] An exception occurred while iterating over the results of a query for context type 'sdonboarding.Server.Models.SalesManagementContext'.
System.Net
.Sockets.SocketException (11004): The requested name is valid, but no data of the requested type was found. at
System.Net
.NameResolutionPal.ProcessResult(SocketError errorCode, GetAddrInfoExContext* context) at
System.Net
.NameResolutionPal.GetAddressInfoExCallback(Int32 error, Int32 bytes, NativeOverlapped* overlapped) --- End of stack trace from previous location ---
๐งช Investigation Steps
Log Setup: Since I was using Free tier and I did not get anything even after enabling the logs via App Service Logs in Azure. I was not clear what was wrong. I was using Deployment Center and had configured GitHub workflow for continuous deployment. So I did below things to see the logs:
In the .yml file add below code after
dotnet publish
to get the logs at C:\home\site\wwwroot\logs:name: Enable stdout logging in generated web.config run: | $configPath = ".\publish_output\web.config" (Get-Content $configPath) -replace 'stdoutLogEnabled="false"', 'stdoutLogEnabled="true"' | Set-Content $configPath
Doing this will put
stdoutLogEnabled
\=โtrueโ in web.config before deploying.You will be able to check the logs now as I have given in the problem section.
In Azure App Service search Advanced Tools(kudu) => Debug console.
In the kudu console do Using
nslookup
, I discovered the database resolved to an IPv6 address:nslookup db.zovrkyywxxdlnkqglddaz.supabase.co
*** UnKnown can't find db.zovrkyywxxdlnkqglddaz.supabase.co: Non-existent domain
Server: UnKnown
Address: 168.63.125.16
Root Cause
The original Direct Connection hostname (db.zovrkyywxdlnkqglddaz.supabase.co
) did not resolve to a valid IPv4 address, and Azure App Service only supports outbound IPv4. This means that:
From within Azure, the app could not reach the database โ DNS resolution succeeded (AAAA), but there was no routable IPv4 (A) address.
Even though your local machine could connect (supporting both IPv4 and IPv6), Azure could not โ resulting in errors like:
System.Net
.Sockets.SocketException (11004): The requested name is valid, but no data of the requested type was found.
โ The Fix
Supabase provides a session pooler endpoint (e.g., aws-0-ap-southeast-2.pooler.supabase.com
) that:
Is designed for better compatibility, especially in IPv4-only environments
Exposes a public IPv4 address that Azure App Service can connect to
Supabase => Project Settings => Database => Connect => Session pooler
When I updated the connection string to use this session pooler hostname, Username, Password remians same, DNS resolution succeeded with an IPv4 address, and the app connected successfully.
Subscribe to my newsletter
Read articles from Jigyasha Sharma Sati directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
