What Does 502 Bad Gateway Mean? Causes, Checks and Fixes

Understand the 502 Bad Gateway error, how it differs from 503 and 504, what visitors can try, and which upstream checks help site owners find the cause.

What Does 502 Bad Gateway Mean? Causes, Checks and Fixes cover image

A 502 Bad Gateway response means that a server working as a gateway or proxy received an invalid response from an upstream server while handling a request. The message usually points to communication between servers, but the exact cause depends on the site’s infrastructure. A visitor generally cannot fix the provider’s upstream connection from their own device.

Cover photo: imgix on Unsplash.

What a visitor can try

First, reload the page once after a short pause. If the error remains, open the site in a private window or another browser and test a different network. This helps rule out a stale page, a local extension or a network-specific path. Check whether other sites work and look at recent community reports on LiveFault for the affected service. A spike can suggest a shared problem, but it does not confirm the provider’s cause or availability.

If only one site returns 502, wait for its operator to investigate. Avoid repeatedly refreshing a failing page, especially during a service disruption. If you own the site, use your host’s logs and incident tools rather than asking visitors to change their device settings.

Common causes for site operators

  • Unavailable or overloaded upstream: the application server may be down, saturated or restarting.
  • Proxy configuration mismatch: the gateway may be pointing to the wrong host, port, protocol or service name.
  • Connection or TLS failure: the proxy cannot establish a valid connection to the upstream, or the upstream closes it unexpectedly.
  • Deployment or dependency issue: a new release, database problem or unavailable dependency may prevent the application from returning a valid response.
  • Timeout or network path issue: the proxy and upstream cannot exchange data as expected.

Start with timestamps and request IDs from the error page. Correlate proxy and application logs for the same request; check upstream health, recent deployments, resource pressure, DNS resolution and TLS configuration. Roll back a recent change only when evidence points to it and your rollback procedure is safe.

502 vs 503 vs 504

The HTTP standard distinguishes these responses. 502 indicates an invalid response received by a gateway or proxy. 503 Service Unavailable indicates that the server is temporarily unable to handle the request, commonly due to overload or maintenance. 504 Gateway Timeout means the gateway did not receive a timely response from an upstream server. Real systems may use these codes imperfectly, so inspect the surrounding logs rather than relying on the code alone.

These definitions come from RFC 9110, HTTP Semantics. If you are a visitor and the error persists across browsers and networks, the website operator is best placed to investigate. If you are the operator, publish a clear status update and include the time window and affected functionality.

Rate this article

0.0 out of 5 · 0 ratings

Sign in to rate this article.

Discussion

No comments yet.

Complete the Cloudflare security check before submitting.

Comments that match our harmful-content filter are held for review.

On this page

Contents

Your privacy

Choose which optional storage Livefault can use. You can change these choices at any time from Cookie settings in the footer.