HTTP 502 BAD GATEWAY

A proxy or gateway got an invalid response from the upstream server. 502 belongs to the 5xx server error class and is defined in RFC 9110.

Zero retention: your headers never leave this browser. Verify it yourself in DevTools.

Loading the workbench.

About HTTP 502

What Does HTTP 502 Bad Gateway Mean?

A proxy or gateway got an invalid response from the upstream server. The code is registered with IANA and defined in RFC 9110.

Server error: the server failed to fulfill a valid request. Every code from 500 to 599 shares that general meaning, so a client that does not recognise 502 must treat it like 500.

When Do You See a 502 Response?

502 Bad Gateway comes from a proxy, load balancer, or CDN that tried to reach the upstream application and got an invalid response or none at all. Typical causes are a crashed or restarting app process, the upstream listening on a different port, a TLS mismatch between proxy and origin, an upstream response with malformed headers, or a firewall blocking the proxy. nginx, Cloudflare, AWS load balancers, and Heroku routers all produce it.

How Do You Fix a 502?

Check whether the upstream service is running and reachable from the proxy, and read the proxy's error log, which usually names the exact failure such as connection refused or upstream prematurely closed. Confirm ports, protocols, and certificates match on both sides. Clients can retry idempotent requests after a short delay, since 502s during deploys are often brief. Persistent 502s need a fix on the server side.

What Does a 502 Response Look Like?

HTTP/1.1 502 Bad Gateway
Server: nginx
Content-Type: text/html

502 is not cacheable by default: a browser or CDN stores it only when Cache-Control or Expires explicitly allows it.

To inspect a real one without sending it anywhere:

  1. Copy the response headers from your browser Network tab, or from curl -i.
  2. Paste them into the Header decoder to see every header explained.
  3. Check caching in the Cache lane.

Which Status Codes Are Related to 502?

Browse every code on the HTTP status codes page.

What Other Lanes Are in the Reference Section?

  • HTTP status codes: Every IANA-registered status code, with a page per code.
  • MIME types: File extensions to Content-Type, searchable both ways, plus a Content-Type parser.
  • HTTP methods: GET, POST, PUT, PATCH, DELETE and the rest: safe, idempotent, cacheable.

Elsewhere in 2http: Header decoder, Cookie decoder, Cache-Control decoder, CORS checker, User-agent parser, and all eleven lanes on the 2http home page. Part of the 2suite.io privacy-first ecosystem.

Frequently Asked Questions

What is the difference between 502 and 504?

Both come from a gateway. 502 means the upstream sent an invalid response or refused the connection. 504 means the upstream did not answer in time.

Why do I see 502 errors during deployments?

While the application restarts, the proxy cannot reach it and reports 502. Rolling deploys and health checks that drain traffic first avoid this.

Is HTTP 502 an error?

Yes. 502 is a server error response: the server failed to handle a valid request, so retrying later may work.

Is a 502 response cacheable by default?

No. Caches store a 502 only when Cache-Control or Expires explicitly allows it.

How Can You Verify That Nothing Leaves This Browser?

You do not have to take our word that your headers stay here. Developer tools show every request a page makes, so you can watch this page work and confirm that nothing is sent. The check takes under a minute.

  1. Open your browser developer tools with F12, or Cmd+Option+I on a Mac, and select the Network tab.
  2. Reload the page and let it finish. You will see the page's own files, its web fonts, and one anonymous page-view request. Nothing has been typed yet, so none of them can contain your headers.
  3. Click the clear icon in the Network tab so that the log is empty.
  4. Paste real headers into any lane and read the result.
  5. Look at the Network tab again. It is still empty. For extra proof, turn on offline mode after the page loads and every lane keeps working.

Only two things can add a line to that log, and neither carries your headers. Submitting the feedback form sends the vote and comment you typed. Typing characters in a script the page has not displayed yet, such as Cyrillic or Greek, can make the browser fetch the matching font file, and that request names only the font.

2http never sends a request on your behalf: the request builder writes code for you to run, and the meta inspector reads source you paste instead of fetching a URL. The production site also sends a Content-Security-Policy header that tells your browser to refuse connections to anywhere except this site and the anonymous analytics endpoint.

Was this helpful?