502 Bad Gateway

What a 502 Bad Gateway error is, its common upstream and proxy causes, how Googlebot handles it, and the impact on crawling and indexing.

First published: Jun 28, 2026 · Last updated: Jul 17, 2026 · Advanced
demand #1 in HTTP Errors#1 in HTTP Status Codes#4 in Technical SEO#8 on the site
1 evidence signal on this page

A 502 Bad Gateway means a proxy or gateway in front of your site (a CDN, load balancer, or reverse proxy) got an invalid response from the origin server behind it. It's an infrastructure problem, not a Search Console one. Google's documentation groups 502 with 500 and 503 under one 5xx treatment: crawling slows in proportion to how many URLs error, content from 5xx responses is ignored, and pages get dropped from the index if the errors persist. Google doesn't publish a specific safe-duration threshold or an automatic-recovery guarantee, so a brief spike carries much less practical risk than one that keeps recurring — but it isn't officially risk-free. Diagnose it by layer (CDN, reverse proxy, origin), and correlate branding or error pages with headers, trace IDs, and logs rather than trusting the error page alone.

TL;DR — A 502 is a proxy/gateway-layer failure: RFC 9110 §15.6.3 defines it as a gateway or proxy receiving an invalid response from an inbound server. It’s distinct from a 500 (origin app errored) and a 503503 Service Unavailable is the HTTP status code a server returns when it's temporarily unable to handle a request — usually because of overload or planned maintenance. It tells crawlers 'come back later' instead of 'this page is gone,' which is why Google recommends it (paired with a Retry-After header) for short, planned downtime. (origin deliberately unavailable). Google’s documentation groups 500, 502, and 503 under one 5xx treatment — crawl rateCrawl rate is how fast a search engine crawler fetches pages from your site — the number of simultaneous requests it makes and the delay between them. Google sets it automatically based on your server's health; it's the supply side of crawl budget, not a ranking factor. drops proportionally to the number of erroring URLs, 5xx content is ignored, and persistent errors drop pages from the indexStoring a crawled page in the search index so it can appear in results. Crawled is not the same as indexed — Google selects what to keep, and indexing isn't guaranteed.. Recovery is gradual once 2xx resumes, though Google publishes no fixed timeline. Duration matters, but there’s no official threshold: brief spikes carry much less practical risk, while errors that keep recurring are what put pages at real risk — Mueller’s Nov 2025 remarks put that informally around multiple days, not as a documented SLA. Diagnose by layer — CDN, reverse proxy, or origin — and correlate evidence across hops rather than trusting a branded error page alone.

What a 502 actually signals

RFC 9110 §15.6.3 defines 502 specifically: a gateway or proxy receiving an invalid response from an inbound server it accessed while trying to fulfill the request. That spec boundary matters — it identifies where the gateway observed the failure, not necessarily which hop caused it. The 502 status is evidence of a boundary failure, not proof the origin application is broken. That single distinction is what most competitor “13 ways to fix it” posts blur over, and it’s why the diagnosis below is layered rather than flat. Evidence for this claim A 502 response means a gateway or proxy received an invalid response from an upstream server. Scope: RFC 9110 defines the gateway response semantics; it does not identify which infrastructure layer caused a specific failure. Confidence: high · Verified: IETF: RFC 9110 §15.6.3 — 502 Bad Gateway

Contrast the confusable 5xx codes:

  • 500 Internal Server ErrorA 500 Internal Server Error is a generic HTTP status code — RFC 9110 defines it as an unexpected condition that stopped the server from fulfilling the request, and nothing more. The request may have been fine — something broke server-side while generating the response. For SEO, an isolated 500 is typically retried, but persistent, site-wide 500s get Google's documented response: slower crawling and, if the errors don't clear, eventual removal from the index. — the origin application itself errored (a code bug, an unhandled exception, resource exhaustion). The origin answered, and the answer was “I broke.”
  • 502 Bad GatewayA 502 Bad Gateway is an HTTP server error a gateway or reverse proxy (a CDN, load balancer, or proxy like Nginx) returns when it gets an invalid or no response from the upstream origin server it was trying to reach. It signals a communication failure *between* servers, not necessarily that the origin itself is down. For SEO, Google treats 502 exactly like 500 and 503: crawling slows, and persistent errors eventually get pages dropped from the index. — the proxy got a malformed or invalid answer from upstream (RFC 9110 §15.6.3).
  • 503 Service Unavailable503 Service Unavailable is the HTTP status code a server returns when it's temporarily unable to handle a request — usually because of overload or planned maintenance. It tells crawlers 'come back later' instead of 'this page is gone,' which is why Google recommends it (paired with a Retry-After header) for short, planned downtime. — the origin is deliberately unavailable; this is the intentional, Google-sanctioned “come back later” code you use for planned maintenance, ideally with a Retry-After header.
  • 504 Gateway TimeoutA 504 Gateway Timeout is an HTTP 5xx server error a gateway or proxy (a CDN, load balancer, or reverse proxy) returns when it doesn't get a timely response from the upstream server behind it. Unlike a 502 (a bad/garbled response) or a 503 (server explicitly unavailable), a 504 means no response arrived in time. For SEO, isolated 504s are retried and tolerated, but sustained 504s and timeouts make Googlebot slow its crawl and eventually drop pages from the index. — the proxy waited for upstream and got nothing before its timeout expired (RFC 9110 §15.6.5). (502 = bad answer; 504 = no answer in time.)

The practical upshot: 503 is the code you choose on purpose; 502 is the code that happens to you when infrastructure fails.

How Googlebot handles a 502

Here’s the part worth groundingGrounding is anchoring an AI model's answer to source documents it retrieves at the moment you ask — not to the patterns frozen into its weights during training. Retrieval-Augmented Generation (RAG) is the most common way to do it. in Google’s actual documentation rather than the hand-wavy “it can hurt rankings” you’ll read elsewhere. Google’s HTTP and network errors doc lists 502 (bad gateway) as a 5xx code and gives all 5xx codes the same treatment:

  • Crawl rateCrawl rate is how fast a search engine crawler fetches pages from your site — the number of simultaneous requests it makes and the delay between them. Google sets it automatically based on your server's health; it's the supply side of crawl budget, not a ranking factor. drops, proportionally. Google decreases the crawl rate for the site, and the decrease is proportionate to how many individual URLs are returning a server error. A handful of 502s is minor; a site-wide 502 is a firm “slow down.”
  • 5xx content is ignored. Anything Google receives from a URL returning a 5xx is ignored — it won’t index a 502 error page as your content.
  • Index preservation is temporary. Already-indexed URLs stay in the index at first, but Google’s indexingStoring a crawled page in the search index so it can appear in results. Crawled is not the same as indexed — Google selects what to keep, and indexing isn't guaranteed. pipeline removes URLs that persistently return a server error.
  • Recovery is automatic and gradual. Once the server starts responding with 2xx again, Google gradually increases the crawl rate back up. No resubmission, reconsideration request, or “validate fix” heroics are needed for ordinary recovery — that button just tells Google to recheck sooner.

The single most important takeaway: 502 is treated the same as 500 and 503. It is not “less serious” because it originates at the proxy/CDN layer instead of the origin app. There’s no documented leniency for 502. Evidence for this claim Google handles 502 with its general 5xx behavior: reduced crawling, ignored response content, and eventual removal of persistently failing URLs. Scope: Google explicitly lists 502 among 5xx server errors; it does not guarantee that a particular short outage has no ranking effect. Confidence: high · Verified: Google: How HTTP status codes affect Google's crawlers

Duration is the whole story

Whether a 502 actually hurts you comes down to how long it lasts — but Google doesn’t publish a fixed safe-duration or a fixed drop-out threshold, so treat the following as practical color, not an SLA:

  • A brief spike (minutes to a few hours) → Google’s crawl-rate reduction scales with how many URLs are erroring, so a short, small-scale spike has limited practical impact and generally isn’t worth chasing in Search ConsoleA free Google service that reports how a site performs in Google Search and surfaces problems with how Google crawls, indexes, and serves it. It's first-party data straight from Google — but you don't need it to appear in results.. Nothing in Google’s documentation formally exempts short errors — it’s a matter of degree, not a hard cutoff.
  • An error that keeps recurring or stays up → this is the window where Google’s “persistently return a server error” language applies, and pages can start dropping out of the index. Google doesn’t define “persistently” as a specific number of days. Mueller’s public comment (below) put it informally around multiple days, with recovery being fairly quick once the site is healthy — but that’s one practitioner’s read on a specific incident, not a documented rule you can rely on for every site or CDN.

This maps loosely onto the November 2025 Cloudflare outage, when a wave of sites threw 5xx errorsThe 4xx (client error) and 5xx (server error) HTTP status codes a server returns instead of a successful 2xx — and how Google treats each class very differently. through no fault of their own. Mueller’s public reply on Bluesky was that 5xx crawlingCrawling is how search engines use automated bots (like Googlebot and Bingbot) to discover URLs and download pages. A page has to be crawlable to be indexed, but crawling on its own isn't a ranking factor. slows down but “ramps back up” — see the Quotes tab for the exact wording and sourcing caveats, including a separate “multiple days” comment relayed through a third-party recap rather than verified against the original thread. A short, provider-confirmed outage is close to a best case: it’s visible, it typically resolves on its own, and once the provider confirms recovery and your own 2xx responses have resumed, the reasonable response is usually to hold off on infrastructure changes rather than make them reactively.

Diagnosing a 502 by layer

Because a 502 is a communication failure between servers, the fastest way to find it is to work down the stack — CDN, then reverse proxy, then origin — rather than running through a flat checklist. (The Decision Trees tab has this as a walk-through.)

One caution before you start: a branded error page, a provider’s name in a header, or the “look” of an outage is one evidence signal, not proof of which hop failed. Correlate it with response headers, request/trace IDs, and timestamped logs on both sides of the hop before concluding “it’s the CDN” or “it’s my origin.”

CDN / edge layer

  • Upstream timeout: the edge node couldn’t get a response from origin in time.
  • The edge can’t reach origin at all — DNS resolution failure, SSL/TLS handshake failure, or origin firewall/security blocking the CDN’s IP ranges.
  • Documented causes vary by provider: Cloudflare’s own troubleshooting docs describe origin-connectivity and timeout scenarios specific to its edge network, while AWS CloudFront documents its own set of TLS, DNS, port, and origin-function causes — check your specific CDN’s docs rather than assuming one provider’s cause list applies to another.
  • The CDN provider’s own outage (Cloudflare, Fastly, AWS, etc.) — a mass-502 event across unrelated sites that has nothing to do with your server’s health; confirm this against the provider’s status page, not just the branding on the error page.

Reverse proxy / load balancer layer (Nginx, Apache mod_proxy, HAProxy)

  • Backend timeout or connection refused.
  • A misconfigured proxy_pass / upstream block pointing at the wrong place.
  • Backend pool exhaustion — every upstream worker is busy.
  • SSL/TLS mismatch between the proxy and the backend.

Origin server layer

  • Application/PHP-FPM crash or restart, or an OOM kill (memory limit exceeded).
  • Database connection exhaustion.
  • A deployment/restart causing brief unavailability.
  • A WAF or security plugin blocking legitimate proxy or crawlerA crawler — also called a spider or bot — is an automated program that fetches web pages, extracts their links, and queues new URLs to visit. Search engines use crawlers to discover and download content for their index. IPs as if they were attackers — this is the sneaky one, because normal browsers work fine while the proxy (or GooglebotGooglebot is Google's web crawler — the software that fetches pages so Google can index and rank them. It comes in two variants, Googlebot Smartphone (primary, under mobile-first indexing) and Googlebot Desktop, and runs an evergreen Chromium renderer.) gets 502s.

That last pattern is worth calling out: if only Googlebot or only requests via the CDN get 502s while normal browsers don’t, you’re looking at a bot-specific block or a varying-response issue, not a true outage. Test direct-to-origin vs. via-CDN, and verify what Googlebot actually sees with Search ConsoleGoogle's free tool for monitoring crawling, indexing, and search performance.’s URL Inspection live test rather than assuming ongoing impact from a Server error (5xx) report that may already be stale.

Fixing and preventing 502s

Fixes are layer-specific, and who should make them differs by role:

  • Visitor — nothing to fix. Reload once, try a different network if you suspect a local issue, and otherwise wait; browser-side changes can’t repair a server-to-server failure.
  • Site owner without infrastructure access — confirm scope and check status pages/logs first (see the checklist below), then escalate to your host, CDN support, or dev team rather than guessing at a fix.
  • Host / CDN / application owner — correct the proxy/upstream config, raise timeouts and backend capacity where the origin is the actual bottleneck, and stagger deploys so restarts don’t blip the whole pool. Treat WAF allowlisting, firewall changes, and proxy/upstream config edits as changes that need sign-off — apply them only after logs and provider evidence actually show a firewall or access-control failure, not as a first-response guess; allowlisting a CDN or crawler isn’t a generic 502 fix.

For prevention, the boring stuff wins: uptime monitoring with alerting, server and proxy error-log monitoring, watching your Search Console crawl-stats Host statusThe at-a-glance availability indicator at the top of Google Search Console's Crawl Stats report. It shows whether Googlebot hit significant problems reaching your site in the last 90 days across three checks — robots.txt fetching, DNS resolution, and server connectivity. and Server error (5xx) trend, and correlating spikes against your CDN and DNS providers’ status pages so you can tell “my problem” from “their outage” in seconds.

Related codes worth keeping straight sit right next door in this cluster: the origin 500A 500 Internal Server Error is a generic HTTP status code — RFC 9110 defines it as an unexpected condition that stopped the server from fulfilling the request, and nothing more. The request may have been fine — something broke server-side while generating the response. For SEO, an isolated 500 is typically retried, but persistent, site-wide 500s get Google's documented response: slower crawling and, if the errors don't clear, eventual removal from the index., the intentional 503503 Service Unavailable is the HTTP status code a server returns when it's temporarily unable to handle a request — usually because of overload or planned maintenance. It tells crawlers 'come back later' instead of 'this page is gone,' which is why Google recommends it (paired with a Retry-After header) for short, planned downtime., and the timeout 504A 504 Gateway Timeout is an HTTP 5xx server error a gateway or proxy (a CDN, load balancer, or reverse proxy) returns when it doesn't get a timely response from the upstream server behind it. Unlike a 502 (a bad/garbled response) or a 503 (server explicitly unavailable), a 504 means no response arrived in time. For SEO, isolated 504s are retried and tolerated, but sustained 504s and timeouts make Googlebot slow its crawl and eventually drop pages from the index..

Try it live

This is a real endpoint on this site — not a simulation. Hit it from the button, open it in a new tab, or curl -i it from your terminal, and the server answers with the actual status code this article is about.

Open in new tab ↗

Add an expert note

Pin an expert quote

New person? Create their unclaimed profile at /admin/experts/ → Pin a quote first.