RackUp IT - View Cloud Hosting Plans

Get started now or speak directly with our engineering team for specialized assistance.

Logo
DevelopmentWEB & APPCalculatorTOOLServicesProductBlogOur TeamCareers
View Plans
Home>Blog>502 Bad Gateway: What It Means and How to Fix It
DevOps & Tutorials

502 Bad Gateway: What It Means and How to Fix It

Alex Vance
Alex Vance
Published Nov 15, 2026•✓ Verified Expert Reviewed•4 min read
502 Bad Gateway: what it means and how to fix it

Key Takeaways

  • ✓A 502 means a gateway or proxy got no valid response from the server behind it.
  • ✓Visitors: reload, try another network, try a private window.
  • ✓Site owners: test the app directly, check it is running, read the proxy error log.
  • ✓Short outages do little SEO harm; long ones get pages dropped.

Table of Contents

  • •502 Bad Gateway: What It Means and How to Fix It
  • •502 Bad Gateway: What It Means and How to Fix It
  • •What the Error Looks Like
  • •If You Are a Visitor
  • •What Causes a 502 Bad Gateway
  • •If It Is Your Website: Find the Failing Layer
  • •Fixes by Platform
  • •Nginx
  • •Apache
  • •Cloudflare
  • •WordPress
  • •Docker
  • •502 vs 500, 503 and 504
  • •Does a 502 Hurt SEO?
  • •Frequently Asked Questions

502 Bad Gateway: What It Means and How to Fix It

A 502 Bad Gateway error means one server asked another server for the page and got an invalid answer, or no answer at all. The server you reached is working as a gateway or proxy (for example Nginx, a load balancer or Cloudflare), and the server behind it failed. It is a server-side problem, so in most cases there is nothing wrong with your device or your connection.

502 Bad Gateway: What It Means and How to Fix It

This guide has two parts. If you are a visitor, the first part shows the few things worth trying. If the site is yours, the second part shows how to find the server that failed and fix it.

What the Error Looks Like

The wording depends on the software that shows it. These all mean the same thing:

  • 502 Bad Gateway with nginx underneath

  • Error 502 or HTTP Error 502 - Bad Gateway

  • 502 Proxy Error (Apache)

  • 502 Server Error: The server encountered a temporary error (Google services)

  • A Cloudflare page titled Bad gateway with error code 502

If You Are a Visitor

A 502 is usually temporary. Try these in order:

  1. Reload the page after a minute. Many 502s clear when the site's app restarts.

  2. Check whether the site is down for everyone by opening it on mobile data or on another device.

  3. Open the page in a private window. If it loads there, clear the browser cache and cookies for that site.

  4. Turn off your VPN or proxy for a moment. Some sites block or fail through certain exit servers.

  5. Restart your router only if several unrelated sites show the error.

If none of this helps, the fault is on the website's side and only its owner can fix it.

What Causes a 502 Bad Gateway

CauseWhat is happening
The application is not runningPHP-FPM, Node.js, Gunicorn or a container has crashed or was never started
Wrong address or portThe proxy forwards requests to a port or socket nothing listens on
The application is overloadedAll workers are busy or the server ran out of memory, so connections are dropped
Firewall or network blockThe proxy can't reach a backend on another server
DNS problemThe proxy can't resolve the backend's hostname, or the domain points at an old IP address
Bad responseThe backend closes the connection early or sends headers the proxy can't accept

If It Is Your Website: Find the Failing Layer

Work from the outside in. The first layer that answers correctly tells you the fault is in front of it.

  1. Test the origin directly. From the server itself, request the app without the proxy, for example curl -I http://127.0.0.1:3000 (use your app's port). If this fails, the app is the problem.

  2. Check that the app is running: systemctl status php8.3-fpm, pm2 status or docker ps, depending on your stack.

  3. Read the proxy's error log. It names the reason, for example connect() failed (111: Connection refused).

  4. Check memory: free -h and dmesg | grep -i "out of memory" show whether the kernel killed the app.

Fixes by Platform

Nginx

Read /var/log/nginx/error.log and match the message to its cause. Our Nginx 502 Bad Gateway guide covers ten causes with the exact fix for each, including PHP-FPM socket and worker problems.

Apache

Apache shows a 502 as a "Proxy Error" when mod_proxy can't get a valid reply from the backend. Check the Apache error log, confirm the backend address in your ProxyPass line, and make sure the backend service is running.

Cloudflare

There are two kinds of Cloudflare 502. If the page shows Cloudflare branding only, the problem is inside Cloudflare's network and you can check its status page. If the page shows your host as the failing part, Cloudflare reached your server and your server returned the 502, so fix it at the origin with the steps above.

WordPress

The common causes are PHP-FPM running out of workers or memory, and a plugin or theme that crashes PHP. Restart PHP-FPM, then rename the wp-content/plugins folder to turn all plugins off and test again. See common WordPress errors for related messages.

Docker

Check that the container is running and that the proxy points at the right container name and internal port. Read the container output with docker logs.

502 vs 500, 503 and 504

CodeMeaning
500 Internal Server ErrorThe application itself failed while handling the request
502 Bad GatewayA proxy got an invalid response, or no response, from the server behind it
503 Service UnavailableThe server is up but refuses requests for now (overload or maintenance)
504 Gateway TimeoutA proxy waited for the server behind it and gave up

For other codes, see common Nginx errors.

Does a 502 Hurt SEO?

A short outage does little harm: Google retries pages that return server errors. Google's documentation says that pages which keep returning 5xx errors are crawled more slowly and are eventually dropped from the index, so a 502 that lasts for days needs fixing quickly.

Frequently Asked Questions

Is a 502 Bad Gateway my fault?
Usually not. It is a server-side error. If only one site shows it and it also fails on another network, the site's owner has to fix it.

How long does a 502 error last?
It lasts until the failed server or application behind the proxy answers again. That can be seconds during a restart, or much longer if a service has crashed and nobody has restarted it.

Can a 502 be caused by too much traffic?
Yes. When the application has no free workers or the server runs out of memory, the proxy gets no valid reply and returns 502.

What is the difference between 502 and 504?
With a 502 the proxy received an invalid response or the connection failed. With a 504 the proxy received nothing before its timeout ran out.

← Previous ArticleFirebase Alternatives in 2026: Backends With Your Own DatabaseNext Article →The WordPress 5-Minute Install, Step by Step (2026)
Interactive 60-Second Tool

Unsure Which Cloud Hosting Plan Fits Your Site?

Answer 4 quick diagnostic questions to estimate the server CPU, RAM and storage you need with transparent pricing.

Free Migration 99.9% Uptime Target
Calculate My Hosting Build
Alex Vance
Written ByAlex Vance

Cloud Infrastructure Engineer.

99.9% Uptime Target

RackUp IT - View Cloud Hosting Plans

View Hosting Plans

View Hosting Plans

CONTENTS

  • 502 Bad Gateway: What It Means and How to Fix It
  • 502 Bad Gateway: What It Means and How to Fix It
  • What the Error Looks Like
  • If You Are a Visitor
  • What Causes a 502 Bad Gateway
  • If It Is Your Website: Find the Failing Layer
  • Fixes by Platform
  • Nginx
  • Apache
  • Cloudflare
  • WordPress
  • Docker
  • 502 vs 500, 503 and 504
  • Does a 502 Hurt SEO?
  • Frequently Asked Questions

Categories

  • VPS Hosting
  • DevOps & Tutorials
  • WordPress Hosting
  • Cloud Hosting
  • Server Stack
  • Networking & Security
  • Web Hosting / Managed Cloud
  • E-Commerce
  • Hosting & SEO
  • Hosting Benchmarks
  • Cloud Backup & DevOps
  • Managed VPS

Recent Posts

  • Vultr Alternatives in 2026: VPS Hosting for Developers Compared
  • Docker Port Mapping Explained: -p, EXPOSE and Compose ports
  • Bluehost Alternatives (2026): WordPress Hosting Without the Renewal Price Jump

Tags

502 bad gatewayhttp errorsnginxtroubleshooting

Related Posts

Docker port mapping coverDevOps & Tutorials
Nov 26, 2026

Docker Port Mapping Explained: -p, EXPOSE and Compose ports

How Docker port mapping works: the -p syntax, EXPOSE vs publishing, Compose ports, service names on the network, and the UFW security detail most guides skip.

Read Article →
Docker Engine vs Docker Desktop coverDevOps & Tutorials
Nov 24, 2026

Docker Engine vs Docker Desktop: Which One Do You Need?

Docker Engine is the open-source runtime for Linux; Docker Desktop is a desktop app with a VM, GUI and its own licence. Which to use on servers and laptops.

Read Article →
ERR_CONNECTION_REFUSED: causes and fixesDevOps & Tutorials
Nov 18, 2026

ERR_CONNECTION_REFUSED: What It Means and How to Fix It

ERR_CONNECTION_REFUSED means your browser reached the address and the connection was rejected. Fixes for visitors, for localhost and for server owners.

Read Article →
Logo

Expert Web & App Development, UI/UX Design, Branding, and Consulting to scale your business.

Company

  • About Us
  • Blog
  • Contact
  • Our Team
  • Careers

Services

  • Web Development
  • App Development
  • UI/UX Design
  • Consulting
  • Managed WordPress VPS
  • Website Speed Test

Subscribe to our newsletter

We accept
  • bKash
  • Nagad
  • Rocket
  • Upay
  • CellFin
  • Meghna Pay
  • OK Wallet
  • Tap
  • mCash
  • DBBL Nexus
  • Visa
  • Mastercard
  • American Express
  • Crypto
Pay with Visa, Mastercard, American Express, DBBL Nexus, CellFin, Rocket, bKash, Tap, Meghna Pay, Nagad, mCash, Upay and OK Wallet. Verified by EPS

© 2026 Rackup IT Solution. All rights reserved.

Privacy PolicyTerms of Service