HTTP 502

HTTP 502 Bad Gateway — Meaning, Causes & How to Fix

The server, acting as a gateway or proxy, received an invalid response from the upstream server.

Code
502
Name
Bad Gateway
Class
5xx Server Error
Specification
RFC 9110 §15.6.3
Cacheable by default
Only with explicit Cache-Control / Expires

What HTTP 502 means

502 Bad Gateway is returned by a proxy, load balancer or CDN when the server behind it (the upstream) sent an invalid response — or, very often, refused or dropped the connection. The proxy itself is fine; the app behind it is not.

Common causes

How to fix it

For site owners

For visitors & developers

SEO impact

Like all 5xx errors, frequent 502s make Googlebot crawl less, and URLs that keep failing can be dropped. Brief 502s during a deploy are not a problem.

Example 502 response

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

Related status codes

504 · Gateway Timeout503 · Service Unavailable500 · Internal Server Error501 · Not Implemented505 · HTTP Version Not Supported

Check or look up another code

Search and filter every code in the HTTP Status Codes tool, browse the full list by class, or read HTTP status codes explained: the complete developer guide.

Open HTTP Status Codes tool →All status codes

Frequently asked questions

What does HTTP 502 mean?

HTTP 502 Bad Gateway is a 5xx Server Error status code. The server, acting as a gateway or proxy, received an invalid response from the upstream server.

What is the difference between 502 and 504?

502: the upstream gave a bad or no valid response (often a crash or refused connection). 504: the upstream did not answer in time.

Is a 502 caused by my internet connection?

Almost never. It is between servers on the site’s side.

Which specification defines 502?

It is defined in RFC 9110 §15.6.3.

Is a 502 response cacheable?

Not by default. A 502 response is only stored by caches when it carries explicit freshness information such as Cache-Control: max-age or Expires.

More PAYATE tools