My Azure application gateway often responds with 504 / 502

cargobuddy 20 Reputation points
2026-06-16T12:41:07.16+00:00

Not sure, but my azure application gateway often results with 504 or 502. The issue is intermittent. For example, this is the graph of the last 4 hours:

User's image

What can be the root cause of this issue?

Azure Application Gateway
Azure Application Gateway

An Azure service that provides a platform-managed, scalable, and highly available application delivery controller as a service.


1 answer

Sort by: Most helpful
  1. Christos Panagiotidis 3,301 Reputation points
    2026-07-15T10:08:03.5233333+00:00

    The confirmed root cause here was the backend request timeout. Application Gateway waits only for the timeout configured in the Backend Setting associated with the route. On v2, when the backend does not respond within that interval, the gateway returns 504; timeout or connectivity failures can also appear as 502 depending on the SKU and failure path.

    Increase the request timeout to a value longer than the slowest legitimate backend response, then verify the change has finished provisioning. Also align any upstream web-server or reverse-proxy timeout so it does not expire first.

    Use Application Gateway access logs and backend latency metrics to choose the value rather than setting it arbitrarily. If 502 responses continue when requests are not slow, check Backend Health, the probe host/path, DNS/NSG/UDR reachability, and the backend TLS certificate/SNI. Increasing the timeout fixes slow responses; it does not fix an unhealthy or unreachable backend.

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.