handy.moe

All tools / Debug tools / Status codes

HTTP 502 Bad Gateway

A gateway or proxy got an invalid response from the server behind it.

This page runs in your browser and makes no requests.

502 Bad Gateway

A gateway or proxy got an invalid response from the server behind it.

Common causes

The app behind nginx, a load balancer or a CDN crashed, restarted, or isn't listening; a wrong upstream port; PHP-FPM down.

What to do

Check that the upstream app is running and on the right address and port, look at both the proxy and the app logs, and watch for crashes and out-of-memory kills.

Class: 5xx Server error · Defined in RFC 9110 §15.6.3

How to use it

  1. Look at the response in your browser's Network tab, or run curl -i URL to see the status line and headers.
  2. Read the response body: many servers explain the exact reason there.
  3. Fix the cause above and send the request again.

Questions

Is 502 an error?

Yes: it is a server error. The request was fine; the server (or something behind it) failed.

Should I retry a 502?

Yes, with exponential backoff, because 5xx errors are often temporary. Respect Retry-After if it is sent.

Where can I see the 502 in my browser?

Open the developer tools (F12 or Cmd+Option+I), go to the Network tab, reload, and look at the Status column. Click the request and open the Response and Headers tabs for the details.