SEO glossary

What is a 502 Bad Gateway?

Learn what HTTP 502 Bad Gateway means, how reverse proxies and CDNs trigger it, differences from 500 and 503, and SEO steps when bots cannot reach your origin.

Technical SEOUpdated August 14, 2026
Also known asHTTP 502Bad Gatewayupstream gateway failure

Definition

A 502 Bad Gateway is an HTTP server error status code indicating an intermediary server—such as a reverse proxy, load balancer, or CDN—received an invalid or missing response from the upstream origin while attempting to fulfill the request.

502 Bad Gateway: the proxy could not talk to your origin

502 Bad Gateway appears when a server acting as a gateway or proxy receives an invalid response—or no response—from the upstream server it needed to complete the request. Users and bots see failure even when the edge CDN or load balancer itself is "up."

For SEO, 502 is a crawl error on the same severity tier as 500 Error—Googlebot cannot obtain a usable document. Chronic 502 patterns signal unreliable delivery paths and shrink how aggressively crawlers return across the host.

502 in the request path

Googlebot → CDN edge → Origin application → Response
                ↑
           502 if origin missing/invalid
GET /products HTTP/1.1
Host: shop.example.com
User-Agent: Googlebot

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

The body often contains vendor-branded error HTML—not your site's template. Search engines still record failed fetch.

502 vs 500 vs 503

CodeWho failsTypical fix layer
500Origin application logicApp code, database
502Gateway ↔ origin communicationCDN config, pool health, TLS to origin
503Service unavailable (often intentional)Maintenance mode, overload shedding
504Gateway timeout waiting upstreamOrigin performance, timeout tuning

Misdiagnosing 502 as app bug sends engineers to PHP logs while the real issue is origin IP block on CDN egress.

Common 502 causes affecting crawlers

Origin down or scaled to zero

Serverless containers asleep; Kubernetes pods not ready; autoscaling lag under crawl burst.

DNS drift

CDN still points to decommissioned origin IP after migration—edge returns 502 for every URL.

TLS between CDN and origin

Certificate expired on origin, SNI mismatch, or HTTP-only origin behind HTTPS-only CDN backhaul.

Firewall and WAF rules

Origin allows only office IPs; CDN ranges blocked—users on VPN see site; Googlebot gets 502 at edge.

Header and protocol mismatch

HTTP/2 to origin quirks, oversized headers rejected upstream—intermittent 502 on heavy pages only.

Rate limiting at origin

Origin throttles CDN connections—502 during parallel bot crawl of large sitemaps.

SEO implications

Indexing stall

URLs returning 502 do not update index state. Previously indexed pages may show stale content until successful recrawl returns 200 OK.

Crawl rate reduction

Googlebot reduces fetch frequency on hosts with sustained 5xx—502 counts toward that reputation.

Geographic variance

Multi-PoP CDNs may 502 only in regions where origin routing differs—Search Console live test from Google may not match your local curl.

Not a ranking "penalty"

502 is operational—fix delivery. Unlike 404 Error, recovery can fully restore rankings if content unchanged.

Diagnosing 502 for SEO incidents

Reproduce with bot user-agent

curl -I -A "Googlebot" https://example.com/large-category
curl -I https://origin.example.com/large-category --resolve example.com:443:ORIGIN_IP

Compare edge vs direct origin response.

Check CDN analytics

502 ratio by path, PoP, and time—spikes aligned with deploys or origin scaling events.

Review origin health checks

Load balancer marks pool healthy while application port wrong—502 until probe logic fixed.

Correlate with crawl stats

Sudden drop in crawled pages per day matching 502 spike in logs.

Fixing 502 without harming SEO post-recovery

  1. Restore healthy origin responses.
  2. Purge CDN cache if stale 502 objects cached—verify Cache-Control on errors.
  3. Confirm HTTPS chain end-to-end—origin cert valid for CDN pull.
  4. Whitelist crawler and CDN IPs in origin firewall thoughtfully—not blanket allow unrelated traffic.
  5. Request indexing on key URLs after stable 200 verified.
  6. Update status page—503 maintenance mode preferable to flapping 502.

Avoid leaving 301 Redirect rules active that point to hosts still returning 502—creates redirect chains ending in failure.

502 and redirect infrastructure

Misconfigured redirect loops between edge and origin sometimes terminate as 502 when proxy limits exceeded—not a true loop visible in browser.

Edge 301 → Origin 301 → Edge → ... → 502

Map full chain with crawl tools.

Example: Black Friday origin saturation

deals.example 502 for 45 minutes when origin max connections hit during sale. CDN served 502 to all paths including /robots.txt.

Impact:

  • Crawl queue stalled sitewide for host
  • New deal URLs delayed indexing into peak season
  • Recovery took two weeks for crawl frequency normalization

Mitigations: origin autoscaling headroom, CDN stale-while-revalidate for static assets, separate health subdomain not on saturated pool, planned 503 Service Unavailable with Retry-After for known capacity limits.

502 vs connection errors

TCP failures and TLS handshake errors may never produce HTTP status—logs show connection reset. SEO tools bucket these alongside 5xx fetch failures. Treat as equally blocking for indexing.

Monitoring checklist

  • Alert on 502 rate > baseline for 5 minutes
  • Synthetic checks through CDN not just origin
  • Bot-specific log slice weekly
  • Post-deploy automated crawl smoke test of top templates

How Crawlox helps with 502 Bad Gateway

Crawlox records 502 and other 5xx codes during authorized site crawls—often through the same CDN path Googlebot uses. Identify whether failures cluster on specific templates, correlate with infrastructure changes, and confirm recovery crawls return 200 OK across the full redirect graph—not only on homepage smoke tests that bypass the failing origin pool.

Related terms

Frequently asked questions

Is 502 worse than 500 for SEO?

Both block indexing on affected URLs. 502 often points to infrastructure—easier to fix globally once upstream health returns—but prolonged 502 equally erodes crawl trust.

Why do I see 502 only for Googlebot?

Bot IP ranges may hit different CDN PoPs, rate limits, or WAF rules. Compare Googlebot user-agent requests with curl from multiple regions.

Can a CDN cause 502 while origin is fine?

Yes. Stale origin DNS, connection limits, SSL mismatch between CDN and origin, or origin firewall blocking CDN IPs produce 502 at the edge.

How is 502 different from 504 Gateway Timeout?

502 means invalid/no response from upstream. 504 means upstream did not respond in time—both are gateway family failures.

Should I use 503 instead of 502 during maintenance?

Yes when possible. Configure load balancers to emit 503 with Retry-After during planned work—clearer temporary signal than 502 from dead upstream pools.

References

Explore authoritative guidance and frameworks related to 502 bad gateway.

Explore every glossary definition

Return to the glossary to search by term, alias, starting letter, or category.

Browse glossary