500, 502, 503 and 504 Errors: A Website Owner’s Guide to Fixing Them

500, 502, 503 and 504 website errors guide

Quick answer. A 500 error means something broke on your server, usually in code or configuration. A 502 means one server got a bad reply from another. A 503 means the server is not ready, often because of overload or maintenance. A 504 means a reply took too long. For the owner of a WordPress or shop site, the first steps are the same: confirm it is down for everyone, check your host’s status, read the error log, then undo the last change.

If you are a visitor seeing one of these on someone else’s site, there is little you can do besides reload, wait and tell the owner. This guide is for the person responsible for the site.

Which error are you seeing?

Code Official meaning, in plain words Usual cause on a business website First place to look
500 Internal Server Error The server hit an unexpected condition Plugin or theme error, PHP problem, bad .htaccess rule Error log
502 Bad Gateway A gateway got an invalid reply from the server behind it PHP process crashed, web server misconfigured, origin down Hosting status, PHP service
503 Service Unavailable The server is not ready to handle the request Overload, resource limit, maintenance mode Resource usage, maintenance file
504 Gateway Timeout A gateway got no reply in time Slow query, long script, slow external API Slow requests, database

The definitions follow MDN’s HTTP reference. All four are server side errors, so clearing your own cache rarely fixes them.

Two neighbours cause confusion. A 403 means access is refused, commonly by a permission or firewall rule. A 404 means the page was not found. Neither means the server has failed.

First ten minutes

Do these in order. Each takes about a minute.

  1. Check from another network. Use your phone on mobile data. If it works there, the cause may be your connection or a firewall blocking your IP.
  2. Check another page. If only checkout fails, treat it as a page problem. If everything fails, treat it as a server problem.
  3. Write down the time and the exact message. You will need both for the logs.
  4. Look at your host’s status page and your email for maintenance notices.
  5. Ask who changed something. Plugin update, theme edit, DNS change, PHP version, new campaign.
  6. Check whether you can log in to the hosting panel and the site admin.
  7. Pause ads pointing at broken pages, so you stop paying for visits that fail.
  8. Tell the team and post a short notice on your social pages if customers are affected.
  9. Open the error log. Find entries at the time you noted.
  10. Decide: undo the last change, or contact the host.

Avoid changing several things at once. If the site comes back, you will not know why, and the fault may return.

Where to find the error log

Setup Where to look
cPanel hosting Metrics, then Errors. Also error_log files inside the site folder
Managed WordPress hosting Logs section of the host’s dashboard
VPS with Nginx Often /var/log/nginx/error.log
VPS with Apache Often /var/log/apache2/error.log or /var/log/httpd/error_log
PHP-FPM The PHP-FPM service log, whose location depends on the server
WordPress wp-content/debug.log, once logging is on
Shopify and similar platforms The platform’s status page. You do not manage the server

To turn on WordPress logging, edit wp-config.php:

define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );

WordPress documentation says logging works only when WP_DEBUG is true, and that WP_DEBUG should not be used on live sites. If you must use it on a live site to find a fault, keep display off, reproduce the problem once, then set it back to false and remove the log. Use a staging copy if you have one.

Reading a log line

Look for four things: the time, the word “fatal” or “error”, a file path and a message.

PHP Fatal error: Allowed memory size of 134217728 bytes exhausted
in /home/site/public_html/wp-content/plugins/example/report.php on line 88

This invented example tells you the limit reached (128MB), and that a plugin folder named example was running. It does not prove the plugin is badly written, since something else may have used most of the memory. It does tell you what to test first.

How to fix a 500 error

A 500 is a general message, so the log matters more here than anywhere else. Common causes, with the checks to make:

Cause How to recognise it Fix
Plugin or theme error Log names a file in wp-content Deactivate it, or roll back the update
PHP version conflict Started after a PHP change Return to the previous version, then update the code
Memory limit “Allowed memory size exhausted” Find the heavy process. Raise the limit if the host allows
Broken .htaccess Apache log mentions .htaccess Rename the file, then regenerate it
File permissions “Permission denied” Ask the host to correct ownership and permissions
Disk full “No space left on device” Remove old backups and logs, or upgrade
Syntax error “Parse error” with a line number Undo the code edit
Corrupted core files Errors in wp-includes or wp-admin Reinstall core files of the same version, after a backup

Test plugins without admin access

Open the hosting File Manager, go to wp-content, and rename plugins to plugins-off. If the site returns, a plugin is involved. Rename the folder back and turn plugins on one by one. Our guide to a WordPress plugin not working explains the safer method for live sites.

On a shop, this stops checkout for a while. Do it at a quiet time, and test a payment afterwards.

Test .htaccess on Apache hosting

Rename .htaccess to .htaccess-old and reload. If the site works, go to Settings, Permalinks in WordPress and save, which writes a fresh file. Then copy custom rules back one block at a time. Security rules and redirects may be in that file, so keep the old copy.

How to fix a 502 error

Most sites pass a request through several layers: perhaps a CDN, then a web server, then PHP, then a database. A 502 means one of those layers answered badly.

  1. Reload after a minute. A service restarting can cause a brief 502.
  2. Find which layer produced it. If you use Cloudflare, see the next section.
  3. Check whether PHP is running. On managed hosting, ask support. On your own server, check the PHP-FPM service.
  4. Read the log for “upstream”. Nginx messages about an upstream closing the connection point to PHP.
  5. Look for crashes after a deploy. A fatal error or memory kill in PHP can surface as a 502.
  6. Check a moved origin. If you changed hosts, the CDN may still point at the old IP.
  7. Check the firewall. The origin must accept connections from your CDN’s addresses.

Is it Cloudflare or your server?

Cloudflare’s documentation gives a useful test for 502 and 504. If the error page carries Cloudflare branding, your origin server returned the error. If it is a plain page without branding, the source may be Cloudflare itself, although Cloudflare notes some origin problems can also cause it.

Other codes in the 520s are specific to Cloudflare:

Code Meaning Detail or first check
520 Origin returned an empty, unknown or unexpected reply Check origin logs
521 Web server is down Check that it is running and not blocking Cloudflare
522 Connection timed out No connection reply within 19 seconds, or no data within 90 seconds of connecting
523 Origin is unreachable Check the origin IP in DNS
524 Connected, then no reply in time Default read timeout of 125 seconds
525 SSL handshake failed Check the certificate and SSL mode
526 Invalid SSL certificate Check expiry and that it matches the domain

How to fix a 503 error

A 503 says the server cannot take the request now. The three usual reasons need different answers.

Stuck maintenance mode

WordPress creates a .maintenance file in the site’s main folder during updates. If an update is interrupted, the file can stay and visitors keep seeing a maintenance message. Delete it using File Manager, then check that the update finished.

Overload or resource limits

Shared hosting limits CPU, memory and simultaneous processes. When you pass them, the host may return a 503.

Sign Likely reason What to do
Happens during a sale or ad launch Real demand Turn on full page caching, upgrade before the next campaign
Happens at the same time daily Scheduled job, backup or import Move it to a quiet hour
Traffic high but few real visitors Bots or attack Use a firewall and rate limits
Only admin or search is slow Uncached, heavy pages Optimise queries, limit search
Started after a new plugin Inefficient code Remove or replace it

Compare the access log with your analytics. Thousands of requests and few sessions in GA4 suggest bots.

Planned maintenance

A 503 is the correct response for short, planned downtime. Google’s guidance says to return an informational page with a 503 when a site must be disabled urgently for one to two days, to use the retry-after header, and to avoid returning 503 for robots.txt because that blocks all crawling. It describes full disabling as suitable only for a few days at most.

Use a maintenance plugin or host feature that sends a real 503. A page that says “back soon” with a 200 status can be indexed as your content.

How to fix a 504 error

A 504 means something took too long. The task may have succeeded or failed, and the gateway gave up waiting either way.

Where it happens Likely cause Fix
Checkout Slow payment or shipping API Check provider status, add sensible timeouts
Product filters or search Heavy database query Add indexes, reduce filters, use a search service
Import or export Too much work in one request Split into batches or run in the background
Report in admin Large query Narrow the date range, run it off peak
Every page Database overloaded or locked Check database processes, ask the host
Form submission Slow email or CRM connection Send in the background

Raising a timeout can be right for a known long task. For normal pages, it only makes visitors wait longer. Aim to shorten the work.

Take care with orders. If a 504 appears after payment, check the payment dashboard before asking a customer to try again, or they may pay twice.

What these errors do to your Google rankings

Google’s documentation on HTTP status codes says 5xx and 429 responses make its crawlers slow down temporarily. Indexed URLs are kept at first, but eventually dropped if errors persist. Once the server returns normal responses, Google gradually increases crawling again. It gives no fixed number of days.

Situation What to do
Down for minutes Fix it. No special search action
Down for hours Fix it, then check Crawl stats and Page indexing in Search Console
Repeated for days Treat as urgent. Keep the 503 honest and restore quickly
Only some URLs fail Export them, find the shared template or query
Important pages dropped After the fix, use URL Inspection on the main ones

Do not redirect broken pages to the home page to hide errors. That removes the content people asked for. For related checks, see what technical SEO covers.

What to send your host

A clear message gets a faster answer.

Domain: example.com.my Error: 502 Bad Gateway, all pages Started: 1 December 2026, about 2:10pm Malaysia time Checked from: office broadband and mobile data Last change: plugin update at 1:50pm, rolled back at 2:20pm with no effect CDN: Cloudflare, branded error page Log entry: [paste] Please check PHP and the web server logs at that time, and tell us whether an account limit was reached.

Ask for the cause and for what will prevent a repeat. “It is working now” is not an explanation.

Who should fix it?

Symptom Start with
Host status page shows an incident Wait, follow updates
Log names a plugin or theme Your developer or maintenance provider
Resource limit reached Host, then review of code and traffic
SSL or CDN code in the 520s Whoever manages DNS and the CDN
Started right after DNS or host move Person who made the move
Signs of a break in Security specialist, and change credentials
Platform such as Shopify Platform support

If unexpected admin users, strange redirects or unknown files appear along with the errors, treat it as a possible compromise. Read what website security involves.

Prevent the next one

Frequency Task
Always on Uptime monitoring of the home page, a product page and checkout, with alerts to two people
Daily Automatic backup kept away from the web server
Weekly Updates on staging first, then live, then a test form and order
Monthly Review error logs, disk use, resource graphs and slow pages
Quarterly Restore a backup to staging to prove it works
Before a campaign Load check, caching review, host notice, change freeze

Monitor for words on the page as well as the status code. A site can return 200 while showing a database error.

The website maintenance checklist has the wider routine.

Before a big sale

  1. Ask the host about limits and how to raise them quickly.
  2. Cache every page that can be cached, and exclude cart, checkout and account pages.
  3. Compress images on landing pages.
  4. Turn off heavy plugins you do not need that week.
  5. Stop code changes 48 hours earlier.
  6. Run a test order on each payment method.
  7. Put a person on duty with access to hosting, DNS and the site.

If resource errors keep returning after you have cleaned up, the plan may be too small. Compare types of web hosting and web hosting in Malaysia. Moving only helps if hosting is the cause. Slow code will be slow on the new server too.

After the incident

Write half a page while it is fresh:

  • What customers saw, and for how long.
  • The cause, with the log line.
  • What fixed it.
  • What would have shown it earlier.
  • One change to prevent it, with an owner and date.

Then check orders, forms and payments from the affected period. Contact customers whose payment succeeded without an order.

Want someone to watch the site?

Our website maintenance services cover updates, backups and fixes. For WordPress, see WordPress website maintenance. If hosting is the problem, see domain and hosting.

Request a Quote with your domain, host, platform and the error you see.

Frequently asked questions

What is the difference between 500, 502, 503 and 504?

A 500 is an unexpected failure on the server. A 502 is a bad reply from a server behind a gateway. A 503 means the server is not ready, often from overload or maintenance. A 504 means a server behind the gateway did not reply in time.

How do I fix a 502 Bad Gateway error?

Reload after a minute, check your host’s status, then read the web server and PHP logs. On Cloudflare, a branded error page points to your origin server. Undo recent changes, and ask the host whether PHP stopped or a limit was reached.

Is a 503 error bad for SEO?

A short one is fine, and Google recommends 503 for brief planned downtime. If server errors persist, Google slows crawling and can eventually drop the affected URLs.

Can visitors fix a 500 error?

Usually not. They can reload, try later or contact the business. The fault is on the website’s server.

Why does my WordPress site show a 503 after an update?

The update may have stopped partway and left a .maintenance file. Delete it from the site’s main folder, then confirm that WordPress, plugins and theme finished updating.

Why does only checkout show a 504?

Checkout often waits for payment, shipping or tax services. Check their status and your logs. Confirm in the payment dashboard whether the customer was charged before they try again.

Will changing hosting stop these errors?

Only if hosting limits or reliability are the cause. If the log points to a plugin, slow query or external service, the same error can follow you to the new host.

Sources

Share it :
Author
Picture of Jasmine Le

Jasmine Le

SEO Specialist
SEO strategist specialising in technical SEO, content optimisation, and organic growth.

Approver
Picture of Ivan Teo

Ivan Teo

Ambassador & Chief Rainmaker
Reviews website strategy and web design content for accuracy and practical value.

Is Your Brand Invisible to AI? Find Out Now.

Grab your free AI Visibility Audit to see if AI engines are recommending your services. 100% free, zero obligations.