Error message · Any site behind a web server, proxy or CDN (nginx, Cloudflare, load balancers)

“502 Bad Gateway”

Your site has a front server (nginx, Apache, Cloudflare or a load balancer) that passes each visit on to the server or app that builds the page. A 502 means that front server asked and got no valid answer back. Visitors see a plain error page instead of your site.

Is your site showing it right now?

The free scan loads your page like a visitor and checks for this message, plus broken links, script errors and phone layout. It also walks your signup, booking or contact form, without sending anything.

​

Free, no signup. Usually done in about a minute.

Why it happens

  • The app or PHP process behind the server crashed, ran out of memory or is restarting
  • A deploy or update left the app not running
  • The app takes too long to answer and the front server gives up
  • A firewall or security plugin blocks your CDN's servers (common with Cloudflare)

How to fix it

  1. Check it isn't just you

    Load the site from your phone on mobile data, or ask someone elsewhere. If it works for them, clear your browser cache and DNS; if it fails everywhere, it's the site.

  2. Restart the app or PHP

    In your hosting panel, restart the site, the app or PHP-FPM. On a server you run, restart the app's service. A crashed process is the most common cause, and a restart often fixes it at once.

  3. Read the server's error log

    The web server's error log (for nginx, /var/log/nginx/error.log) says why the upstream failed: "connection refused" means the app isn't running; "upstream timed out" means it's too slow.

  4. Undo the last change

    If it started after a deploy, a plugin update or a config change, roll that back first and investigate afterwards.

  5. Using Cloudflare? Check the origin

    Cloudflare's own 502 page names the host. Make sure your origin server is up and its firewall allows Cloudflare's IP ranges.

Questions

Is a 502 bad for search rankings?

A short one isn't. If it lasts hours or keeps coming back, search engines crawl less and visitors leave, so it's worth fixing quickly.

What's the difference from 503 and 504?

503 means the server is up but refusing work (often maintenance or overload); 504 means the upstream answered too slowly. All three point to the server behind your front server.

Can Page Canary tell me if this comes back?

Yes. Page Canary checks your key pages every day for this message and others like it, confirms it on a second check, and emails you with the fix. One site is free.

Other error messages