502

502 Bad Gateway Error

Category: HTTP Errors | Platforms: nginx cloudflare aws

What This Error Means

A 502 Bad Gateway error indicates that a server acting as a gateway or proxy received an invalid response from an upstream server. In modern web stacks, this typically means the reverse proxy, like Nginx or Cloudflare, tried to talk to the application backend but received an error, a disconnect, or garbage data.

Common Causes

  • The backend process, such as php-fpm, is not running or has crashed.
  • The upstream server is too busy to respond, causing the gateway to give up.
  • A firewall is blocking the connection between the proxy and the origin.
  • The upstream server took too long to process a complex request, and the gateway closed the connection.
  • The proxy is trying to speak HTTPS to an upstream server that only speaks HTTP.

How to Fix It (For Users)

  1. 1 Refresh the page, as the server might have been temporarily overloaded.
  2. 2 Check the site status using a tool like Down For Everyone Or Just Me to see if it is a global outage.
  3. 3 Clear your cache to ensure you aren't seeing a cached error page.

For Site Owners / Developers

  1. Ensure your application server is running by checking the service status.
  2. Inspect both the Nginx error logs and the application logs for connection failures.
  3. Increase timeouts if the error happens on long-running tasks.
  4. Ensure port 80 or 443 is open to the proxy server in your firewall rules.
  5. If using Cloudflare, ensure your SSL mode matches your origin configuration.

When It Is NOT Your Fault

If the site is experiencing a DDoS attack or the hosting provider is having infrastructure issues.

Check if this outage affects everyone globally

This error often indicates a wider problem. Use our tool to verify if the site is down for everyone.

Check Website Status →

Recommended Tool to Prevent This Error

Prevent server timeouts and resource exhaustion with scalable cloud infrastructure.

High-Performance Cloud Hosting