isitdownnow.siteStatus & Diagnostic Hub

How to Fix 502 Bad Gateway Error (For Visitors & Website Owners)

Published 2026-03-15•7 min read time•Practitioner Verified
Quick Answer Capsule

A 502 Bad Gateway indicates an edge proxy (Cloudflare, Nginx, AWS ALB) received an invalid response from your upstream origin application server. For visitors: hard refresh with Ctrl+F5 or clear DNS cache. For site owners: inspect upstream PHP-FPM/Node.js process status, restart crashed web workers, and check Nginx error logs at /var/log/nginx/error.log.

Interactive Companion Tool

Live Website Status & Uptime Checker

Real-time edge HTTP/HTTPS reachability probe measuring status codes, TTFB latency in milliseconds, server headers, and final resolution state.

Technical Specifications & Benchmarks2026 Reference
Parameter / MetricExact Value / StandardNotes & Operational Context
HTTP Status Code502 Bad GatewayServer error response
Failure DomainBetween reverse proxy and origin applicationEdge proxy reachable; backend dead
Cloudflare IndicatorError 502: Bad Gateway HostOrigin server dropped connection
Default Nginx Error Log/var/log/nginx/error.logInspect for connection refused
Fast Visitor FixCtrl + F5 (Hard cache refresh)Forces bypass of local stale browser cache

1. What Causes a 502 Bad Gateway Under the Hood?

When you visit a website, your request hits an edge reverse proxy (such as Cloudflare, Nginx, or an AWS Load Balancer). The proxy forwards the request internally to the application server (such as Node.js on port 3000 or PHP-FPM via a UNIX socket).

If the application server crashes, runs out of memory, or fails to respond before the proxy's read timeout expires, the reverse proxy returns an HTTP 502 Bad Gateway error.

2. Server Admin Fix: 4-Step Origin Diagnostics

Log into your server via SSH and execute the following commands:

  • Check Memory Pressure: Run `free -m` to see if the Linux Out-Of-Memory (OOM) killer terminated your application worker.
  • Verify Upstream Port: Verify that your Node.js or Docker container is actively bound to the port specified in your Nginx proxy_pass directive (e.g. `http://127.0.0.1:3000`).
  • Increase Proxy Timeouts: If your backend performs heavy calculations, increase `proxy_read_timeout` from 60s to 120s in your Nginx server block.
# Terminal diagnostic sequence to inspect crashed upstream workers
# Check upstream application status (Node.js PM2 or systemd) sudo systemctl status nginx sudo systemctl status php-fpm pm2 status # Inspect recent proxy connection drops sudo tail -n 50 /var/log/nginx/error.log

Frequently Asked Questions

Is a 502 error caused by my internet connection?

Rarely. 502 Bad Gateway is almost always a server-side failure. However, a corrupt local DNS cache can route requests to an outdated IP address.

What is the difference between a 502 and 504 error?

A 502 Bad Gateway means the upstream server sent an invalid or corrupt response. A 504 Gateway Timeout means the upstream server took too long and never responded at all.

Recommended Cloud Host

Need 99.99% Uptime for Your Website?

Deploy ultra-low latency NVMe servers with automated Cloudflare DDoS mitigation, automated backups, and 1-click WordPress staging.

99.99% Guaranteed SLA Uptime
Free SSL & Automated Backups
Global CDN in 280+ Edge Locations
30-Day Money-Back Guarantee

* FTC Disclosure: We may receive affiliate compensation when you subscribe via our partner links at no extra cost to you.

Exclusive Community Discount

Recommended Diagnostic Tools

More Engineering Guides

View all 55 guides