Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Origin server returns 5xx intermittently: how to find and fix it

PRF-061High impactDetectedBy FunnelGuardPublished Updated
On this page

What this issue is

A 5xx status code is a server-side error. The request reached your site, but the server could not complete it. Common ones are 500 (generic failure), 502 (bad gateway: a proxy got a bad answer from the app), 503 (unavailable or overloaded) and 504 (gateway timeout).

The word that matters here is intermittent. The page works when you test it, then fails for a share of visitors. That makes it easy to miss and hard to reproduce.

Why it costs you leads or sales

A visitor who gets an error page rarely retries. If it happens on a landing page, you pay for the ad click and get nothing. If it happens on a form submit or checkout step, you lose a person who was ready to act. Tracking tags often do not load on error pages either, so your ad platforms see fewer conversions and your reports look worse than the real picture.

Where an intermittent 5xx breaks the journey
  1. Ad clickVisitor lands from your campaign
  2. Landing page requestOrigin returns 502 or 503
  3. Form or checkoutNever reached
  4. Conversion tagNever fires

The error appears on some requests only, so the steps after it never happen for those visitors.

Lost leads from a partial failure rateExample numbers
Lost leads from a partial failure rate (example)No errors: 50 leads per 1,000 clicks; 5% of requests fail: 47.5 leads per 1,000 clicks; 10% of requests fail: 45 leads per 1,000 clicks; 25% of requests fail: 37.5 leads per 1,000 clicks019385047.54537.5No errors5% of requests fail10% of requests fail25% of requests failleads per 1,000 clicks

Example: with 50 leads per 1,000 clicks normally, a 10% error rate on the landing page removes about 5 of them. Numbers are illustrative.

How to check if your site has it

Confirm the 5xx errors are real
  1. Read the server access log

    Look for lines with status 500, 502, 503 or 504. Note the URLs and the times. Ask your host where the logs are if you cannot find them.

  2. Read the error log

    Check the web server error log and, for WordPress or PHP sites, the PHP error log. Match entries to the times of the 5xx lines.

  3. Look for a pattern

    Do errors cluster at certain hours, after traffic spikes, during backups or cron jobs, or on one URL only? The pattern points to the cause.

  4. Check your CDN or proxy dashboard

    If you use a CDN or load balancer, look at its origin error reports. Errors there that you cannot reproduce in a browser are a typical sign of intermittent origin failures.

  5. Test repeatedly

    Run the command below in a loop to see how often the page fails.

Request a page 50 times and count status codesbash
for i in $(seq 1 50); do curl -s -o /dev/null -w "%{http_code}\n" https://example.com/; sleep 1; done | sort | uniq -c

How to fix it

The fix depends on what the logs show. These are the most common causes and what to do about each.

Common causes of intermittent 5xx errors
Symptom in logsLikely causeFix
502 or 504 under load, 'max_children reached'PHP workers exhaustedRaise pm.max_children if memory allows, or upgrade the plan
500 with 'Allowed memory size exhausted'PHP memory limit too lowRaise memory_limit and find the heavy plugin or query
500 with 'Error establishing a database connection'Database connection limit or crashCheck max_connections, slow queries and database host health
503 at fixed timesBackup, cron or import job hogging resourcesMove the job off-peak or throttle it
500 right after a deploy or plugin updateFaulty code or plugin conflictRoll back and update one plugin at a time
503 from host with rate or resource noticesShared hosting resource limitsUpgrade or move to a bigger plan
Fix steps by platform
  1. Turn on debug logging

    In wp-config.php set WP_DEBUG and WP_DEBUG_LOG to true and WP_DEBUG_DISPLAY to false. Read wp-content/debug.log after the next error.

  2. Find the culprit plugin

    On a staging copy, deactivate plugins in groups and repeat the load test. Pay attention to page builders, security and backup plugins.

  3. Add full-page caching

    A cache plugin or host-level cache serves pages without running PHP, which cuts load on PHP workers.

  4. Raise limits or upgrade hosting

    Ask your host for the PHP worker count and memory limit, and raise them if the logs show they run out.

How to confirm it's fixed

Confirmation checklist
  • The repeated curl test returns only 200 (or expected redirects) over many requests
  • No new 5xx lines in the access log for at least 24 hours, including your busy hours
  • The error log shows no new fatal errors or worker limit warnings
  • Your form submit and checkout steps complete from a clean browser session
  • CDN or load balancer origin error reports are back to zero

How to prevent it happening again

Prevention habits
  • Test updates and new plugins on staging before going live
  • Schedule backups and cron jobs outside peak ad hours
  • Use full-page caching so most visits do not hit PHP and the database
  • Check resource usage before launching a big campaign and scale up first
  • Set up uptime and journey monitoring on the pages that earn leads, not only the homepage
How an intermittent 5xx often unfolds
  1. Example: 09:00

    Campaign goes live and traffic rises

  2. Example: 09:20

    PHP workers fill up and some requests return 502

  3. Example: 09:40

    Load drops briefly, so the site works when you check

  4. Example: 10:30

    Errors return in the next spike

  5. Example: next day

    Logs reviewed, worker limit raised and caching added

How FunnelGuard handles this

FunnelGuard detects this today. A robot visitor loads your pages and runs your journeys on a schedule, from the EU or the US. If a page load or a confirmation step returns a server error or fails to complete, the check fails.

Because the problem is intermittent, FunnelGuard re-checks a failure from a second region before it alerts you. You then get one alert (email, Slack, Teams, WhatsApp, webhook or PagerDuty) with a screenshot and a likely cause. A check only samples your site at its schedule, so a very brief or rare error can be missed between runs. It tells you something is wrong and where; you still use your server logs to find the root cause.

The Free plan covers 1 site and 2 journeys with daily checks and no card. Paid plans start at $39/month with a 3-day free trial.

Frequently asked questions

See the questions below for quick answers.

Questions people ask

Why does my website sometimes show a 500 or 502 error?

The server is failing on some requests, usually because it runs out of PHP workers, memory or database connections under load, or because a plugin or job crashes. Check the server and PHP error logs for the exact times of the errors to see which.

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

500 is a generic server failure. 502 means a proxy or gateway got a bad response from the app. 503 means the server is unavailable or overloaded. 504 means a gateway timed out waiting for the app.

How do I find the cause of random 5xx errors?

Match timestamps of 5xx lines in the access log with entries in the error log, PHP log and database slow query log. Then look for a pattern such as peak traffic, cron jobs, backups or one specific URL.

Can intermittent server errors hurt my ad results?

Yes. Visitors who hit an error page leave, you still pay for the click, and conversion tags may not fire. That lowers leads and makes campaign data look worse than it is.

Will a CDN stop 5xx errors?

Not by itself. A CDN can serve cached pages while the origin is down, which hides some errors, but uncached pages, form submits and checkout calls still reach the origin and can fail.

Why can't I reproduce the error myself?

Intermittent errors depend on load and timing, so most of your own visits succeed. Run a repeated request test or check logs and monitoring, which record the failures you do not see.

How can I get alerted when my site returns 5xx errors?

Use a monitor that loads your key pages and journeys on a schedule and alerts on failure. FunnelGuard does this with a second-region re-check, then sends one alert with a screenshot and a likely cause.

Does FunnelGuard catch this?

Detected

FunnelGuard checks for this today.

How: page load and confirmation run.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.