Skip to content
WordPress Support

WordPress 502, 503 and 504 Errors Explained

502, 503 and 504 errors all keep visitors out, but each points at a different part of the server chain. Here is what each means and how to narrow down the cause.

A laptop with code on screen in a dark room
7 sections · 7 min read
In this article · 7 sections

Three numbers, three different stories. 502 Bad Gateway, 503 Service Unavailable and 504 Gateway Timeout all mean visitors can’t see your WordPress site, and they often turn up together on the same bad afternoon. But each one points at a different part of the machinery, and knowing which part saves you from fixing the wrong thing.

This post explains what each code means in plain terms, what tends to cause it on a WordPress site, and what you can check yourself before calling anyone.

How a page request travels

It helps to picture the chain. When someone opens your site, the request often passes through several pieces in turn:

  1. A CDN or proxy such as Cloudflare (not every site has one).
  2. The web server, usually Nginx, Apache or LiteSpeed, which receives the request.
  3. PHP, often running as a separate service called PHP-FPM, which actually runs WordPress.
  4. The database, usually MySQL or MariaDB, which holds your content.

Errors in the 5xx range mean something went wrong on the server side of that chain, not in the visitor’s browser. The 502, 503 and 504 codes are specifically about one piece of the chain failing to get a proper answer from the next one, or refusing to take the request at all.

What each code means

Code Plain meaning Typical WordPress cause
502 Bad Gateway The front piece asked the next piece and got a broken or empty reply. PHP-FPM crashed or restarted, or a process was killed for using too many resources.
503 Service Unavailable The server is up but won’t handle the request right now. Overload, host resource limits, WordPress maintenance mode, or a deliberate block.
504 Gateway Timeout The front piece waited for the next piece and gave up. A slow page: heavy plugin, slow database query, or a call to an outside service that hangs.

502 Bad Gateway

The web server or proxy passed the request on and received something it couldn’t use, often nothing at all. On WordPress hosting this usually means PHP stopped responding: PHP-FPM ran out of worker processes, crashed, or was restarted mid-request. If you use Cloudflare and its error page shows the problem at the “Host”, the trouble is at your server, not at Cloudflare.

A 502 that appears for a few seconds and disappears is often a PHP restart during maintenance or a deploy. One that keeps coming back points to something repeatedly exhausting PHP.

503 Service Unavailable

A 503 is the server saying “not now”. It is the one code with an innocent WordPress cause: during updates, WordPress puts a .maintenance file in the site’s root and shows “Briefly unavailable for scheduled maintenance. Check back in a minute.” with a 503 status. If an update is interrupted, that file can stay behind and the message stays with it. We wrote about this separately in our article on WordPress maintenance mode.

Other 503s come from the host. Shared hosting places limits on how many processes, how much CPU and how much memory each account may use. Hit those limits and new requests are turned away until things calm down. Some hosts show their own branded page for this; others show a plain 503.

504 Gateway Timeout

The front piece waited a set time for PHP to finish building the page, and PHP didn’t finish. The page might eventually have loaded; the proxy simply stopped waiting. That makes a 504 a slowness problem in disguise. A product import, a report in the WooCommerce admin, a plugin calling a remote API that is down, or a database query running over a very large table can all push a request past the timeout.

Common causes, from most to least likely

  1. A traffic spike or bot crawl. Aggressive crawlers, login attacks against wp-login.php, or requests hammering xmlrpc.php can consume every PHP worker. Real visitors then get 502 or 503. Our note on what XML-RPC is and whether to disable it is relevant if your logs show that file being hit.
  2. One slow plugin or page. Uncached pages that run heavy queries, search pages, filters on large WooCommerce catalogues, and admin reports are the usual suspects for 504.
  3. Background jobs piling up. When WordPress’s scheduled tasks run on page loads and several heavy ones fire at once, they compete with visitors. A stuck task that retries on every request makes it worse.
  4. Outgoing calls that hang. Plugins that contact licence servers, payment gateways, shipping APIs or social feeds wait for an answer. If that outside service is slow, your page waits too.
  5. A leftover maintenance file. A 503 with the “Briefly unavailable” message after an update.
  6. Server-level trouble. The database service stopped, the disk is full, or PHP-FPM was misconfigured after a PHP version change.
  7. CDN or proxy problems. Less common, but a misconfigured origin address or firewall can make the CDN report gateway errors even when your server is healthy.

What to check yourself

The checks in this section are mostly about looking, not changing. If you reach the point of editing files or deactivating plugins, first confirm that last night’s backup exists and that you can download it, so you’re never one click away from a worse problem.

1. Note the code, the time and the page

Is it every page or only some? Only the shop, only wp-admin, only the search results? Did it start at a particular time, perhaps when a newsletter went out or a scheduled backup started? This information is what anyone diagnosing the problem needs first.

2. Look for the maintenance file

If the message is “Briefly unavailable for scheduled maintenance”, open your host’s file manager and look in the site’s root folder for a file called .maintenance. Files starting with a dot can be hidden, so you may need to switch on “show hidden files”. Deleting it ends maintenance mode. Then check the Updates screen, because whatever was updating may be half-installed.

3. Check the host’s status page and resource graphs

Many hosts publish a status page and show CPU, memory and process usage in the control panel. If your account is at its limit, you have found the shape of the problem. If the whole server is down, it is the host’s problem to fix, and there is nothing to gain from changing WordPress.

4. Read the logs

The server error log, and WordPress’s own wp-content/debug.log if logging is on, often name the plugin or the file that was running when things went wrong. Look for timeouts, “maximum execution time exceeded”, out-of-memory errors, or many requests to the same URL from the same IP.

5. Isolate a slow plugin

If one page or one admin screen times out, deactivate plugins related to that page, ideally on a staging copy. Search, filters, related-products widgets, page builders and statistics plugins are worth testing first. If you can’t reach wp-admin, rename the plugin’s folder in wp-content/plugins/.

6. Take pressure off PHP

Page caching lets the server answer many requests without starting WordPress at all. Blocking abusive bots at the CDN or firewall keeps PHP workers free for real visitors. Moving WordPress’s scheduled tasks to a real server cron, which our post on WordPress cron not running touches on, stops heavy jobs from firing on visitor page loads.

7. Talk to the host with specifics

“The site is down” gets a generic reply. “We’re getting 504s on /shop/ since 3 p.m. IST, PHP-FPM logs show workers maxed out” gets a useful one. Ask whether PHP worker counts, timeouts or plan limits are the constraint.

Reading the codes together

When all three appear in a short period, the story is usually overload. Requests take longer (504), PHP runs out of workers and starts failing (502), and the host or server begins turning traffic away (503). Fixing the slowness, or the source of the extra traffic, tends to clear all three at once.

A 500 Internal Server Error is a different family. It means PHP ran and crashed, typically on a code error, rather than being slow or unavailable. If your site shows a 500, our 500 internal server error fix page covers that path. And if the browser shows no error code at all, just a page that never connects, read our companion post on connection timed out errors.

Preventing repeat outages

  • Use page caching and keep it working after updates.
  • Protect wp-login.php and xmlrpc.php from automated abuse.
  • Schedule heavy jobs (backups, imports, feeds) for quiet hours and in small batches.
  • Remove plugins that call outside services on every page load without a good reason.
  • Set up uptime monitoring so you hear about a 502 before a customer tells you.
  • Review your hosting plan honestly when the site grows. A busy shop on an entry-level plan will keep hitting the same ceiling.

When to call for help

If the site is down right now and the cause isn’t obvious, stop experimenting on the live server; every restart and plugin toggle adds noise to the logs someone will need to read. Our guide to WordPress errors and fixes maps the other server errors if yours doesn’t fit here.

For a site that is offline or a store that can’t take orders, our WordPress site down emergency help is the page to use. Send the error code, the address and the time it started on WhatsApp; we treat a down site as urgent, take a backup before changing anything, and tell you what we found afterwards.

Next in this series: WordPress Connection Timed Out: What It Means

Is Your Website Working Properly?

Get a free website health check from WebMaintor. We'll review your website's speed, security, forms, and technical health — and tell you exactly what needs attention.

No obligation. No automated reports. A real review by our team.