Application Gateway returns `502 Bad Gateway` and backend health shows Unhealthy.
IntermediateTroubleshootingNetwork Connectivity Errors
Answer
Likely causes → Probe path returns non-2xx/3xx, NSG on backend blocks App Gateway subnet, TLS mismatch (backend cert CN doesn't match host name), wrong port, or backend actually down.
Diagnose →
az network application-gateway show-backend-health -g rg -n agw-shop \
--query "backendAddressPools[].backendHttpSettingsCollection[].servers[].{ip:address, health:health, log:healthProbeLog}" -o table
Fix →
- Point the custom probe at a real health endpoint with correct host header
- Allow traffic from the App Gateway subnet on the backend port
- For HTTPS backends, set the correct host name or trusted root certificate
Prevent → Dedicated /healthz endpoints and probes in IaC.
More on Network Connectivity Errors
A VM with a public IP times out on SSH (`ssh: connect to host 20.x.x.x port 22: Connection timed out`).Beginner`nslookup kv-shop.vault.azure.net` from inside the VNet returns a public IP even though a Private Endpoint exists.IntermediateKey Vault returns `Client address is not authorized and caller is not a trusted service.` (ForbiddenByFirewall).BeginnerApp Gateway v2 deployment fails or goes unhealthy after a UDR `0.0.0.0/0 → firewall` was added to its subnet.AdvancedTwo VNets peered but VMs can't communicate; peering state shows `Initiated`.IntermediatePeering creation fails because address spaces overlap.Beginner