Application Gateway
- Typical cause Microsoft documents
- Backend unreachable or unhealthy, or backend time-out exceeded
- Start here
- Gateway section below
Azure 502s come from App Service, Application Gateway or Front Door. Find the layer, then fix probes, NSG and route rules, request time-outs or app crashes.
A 502 on Azure is produced by whichever gateway sits in front of your app. For Application Gateway, Microsoft lists blocked network paths, a default probe that can't reach the backend, a backend time-out (20 seconds by default), an empty or unhealthy pool, and a certificate mismatch. For App Service, the usual causes are slow requests, high memory or CPU, or an unhandled exception. Find the layer first.
Four quick questions, then a straight answer.
From your answers, this is quietly costing you traffic and nobody has the hours to chase it. Scaplet finds every affected page, drafts the fixes and tracks how AI answers mention you.
A data platform shipped 46 fixes without a ticket.
This looks handled. Re-check after a redesign, a migration or a big content push; that is when it breaks.
Your site is small and you have the time. Work through the steps on this page, starting with the pages that get the most traffic.
client -> Front Door -> Application Gateway -> App Service or VM -> your app
(TLS to origin) (probes, time-out) (memory, CPU, crash)curl -sS -o /dev/null -w "origin: %{http_code} %{time_total}s\n" https://your-app.azurewebsites.net/
curl -sS -o /dev/null -w "gateway: %{http_code} %{time_total}s\n" https://www.your-domain.example/
# origin 200 and gateway 502: gateway config, probes or certificate
# origin 5xx or slow: the app, not the gatewayRead the times as well as the codes. A gateway 502 that arrives close to its configured request time-out points at a slow backend. Application Gateway's default is 20 seconds, according to the Microsoft troubleshooting article.
curl -sS -o /dev/null -w "%{http_code}\n" https://httpbin.org/status/502
# observed: 502Succeeded| Property | Value |
|---|---|
| Probe URL | http://127.0.0.1/ |
| Interval | 30 seconds |
| Time-out | 30 seconds |
| Unhealthy threshold | 3 consecutive failures |
Get-AzEffectiveNetworkSecurityGroup -NetworkInterfaceName nic1 -ResourceGroupName testrg
Get-AzEffectiveRouteTable -NetworkInterfaceName nic1 -ResourceGroupName testrg
Get-AzVirtualNetwork -Name vnetName -ResourceGroupName rgNameaz network watcher test-connectivity \
--source-resource '<diagnostic-vm-resource-id>' \
--dest-address '<backend-ip-or-fqdn>' \
--protocol TCP \
--dest-port '<backend-port>'I confirmed these az commands and their flags exist in the installed Azure CLI help, and took the PowerShell and the output interpretation from the Microsoft article; none were run against a subscription.
az network application-gateway http-settings update \
--gateway-name <application-gateway-name> \
--resource-group <resource-group-name> \
--name <backend-http-settings-name> \
--timeout <time-out-in-seconds>In the app's Monitoring, then Metrics, add Average memory working set, CPU time, Memory working set and Requests, and look for a spike that lines up with the 502s.
Microsoft describes it as a no-configuration experience that can discover a problem and guide you to the right information.
Moving to a higher tier or running more than one instance adds capacity, and if the process goes down on one instance the other keeps serving.
Auto-healing recycles the worker process based on triggers you add to the root Web.config, such as memory limits, request counts or request duration. Microsoft says these settings work the same even if the app is not .NET.
Googlebot meets an Azure 502 as one more server error, and Google's status code guide says the crawler eases off when 5xx responses appear. Pages that are already indexed stay for a while but can drop out if the failures do not stop. Which pages suffer depends on the cause: a failed probe empties the whole pool, so every URL behind it fails, while a time-out hits only the slow endpoints. Count affected URLs in your logs to see which you have. See 5xx server errors and the generic 502 Bad Gateway page.
3 questions people ask next, answered from the sources on this page.
20 seconds, according to Microsoft's troubleshooting article. The request time-out is a property of the backend HTTP setting and accepts 1 to 86400 seconds.
On v2, when the backend does not answer in the interval, the gateway retries a second backend pool member. If that also fails the user gets a 504. On v1 the user request gets a 502 directly.
Often. Microsoft lists slow requests, high memory or CPU use, and unhandled exceptions as the usual causes. Check metrics and the Kudu log stream before changing gateway settings.
Run the free audit, then approve the fixes. Every change can be undone.