Skip to main contentমূল বিষয়বস্তুতে যান

Case study Cloudflare WooCommerce

Cloudflare 520 errors on a SiteGround WooCommerce store: tracing them to the host's anti-bot layer

Client
US home-furnishings retailer
Service
Fixed-price root-cause diagnosis
Stack
WooCommerce · Cloudflare Pro · SiteGround
Timeline
Delivered the week before Black Friday

The short answer

The 520 errors were not coming from WordPress, WooCommerce or the server's capacity. SiteGround's anti-bot layer, which sits in front of its Nginx web server, was resetting connections from Cloudflare before they reached the site. Cloudflare shows a connection that closes without a response as error 520. We proved it by matching Cloudflare analytics against the origin's own access logs, and SiteGround confirmed the diagnosis in writing.

≈70%

of 520s were on static files

Images, CSS and JS under /wp-content/ need no PHP, so server load could not explain them.

0

matching errors in the origin logs

Across about 35,000 image requests, the web server logged no challenges and no 5xx errors.

2.4×

more images served from cache

After the caching changes, comparing the same time window.

In writing

root cause confirmed by SiteGround

Their team confirmed the anti-bot layer closes connections that Cloudflare reports as 520.

The problem

A WooCommerce furniture store behind Cloudflare Pro was showing visitors Cloudflare's "Web server is returning an unknown error" page, error 520, thousands of times a day. Product images failed to load and some page views broke, with Black Friday a week away.

The store's team had already done serious work: firewall rules, a rule against add-to-cart crawling and long threads with both vendors. The hosting provider pointed at Cloudflare, and Cloudflare's guidance pointed back at the origin. What they needed was evidence of where the requests were failing, and who could fix it.

How we investigated

We worked read-only, with temporary access to Cloudflare and the hosting control panel. Nothing was changed without written approval.

  1. Split the errors by what was requested

    A slow or overloaded WordPress site fails on pages, because pages run PHP and query the database. We broke the 520s down by path.

    Finding: About 70% were on static files under /wp-content/, mostly product images. Those need no PHP, so "the server is too busy" could not be the main cause.

  2. Match Cloudflare's numbers against the origin's logs

    We counted image requests that missed Cloudflare's cache and went to the origin, then read the web server's own access logs for the same 24 hours.

    Finding: Cloudflare recorded about 4,000 bot-challenge responses and 1,500 520s on images. The origin logs covered about 35,000 image requests and contained none of either. The requests were being stopped before the website saw them.

  3. Rule out the usual suspects with data

    Several plausible explanations were in play, and each could have cost days. We tested each one against the data before changing anything.

    Finding: The ~14,000 daily 504s were answered in 13–17 ms and came from Cloudflare's Early Hints feature, not the server. The 520s continued with HTTP/2 to origin switched off, so that was not the cause. The store's own add-to-cart rule was working: page-level 520s had fallen from about 300 an hour to under 30.

  4. Identify the layer between Cloudflare and WordPress

    With the website cleared, the remaining suspect was whatever sits in front of it. SiteGround runs an anti-bot system ahead of its Nginx web server.

    Finding: That layer either challenges a client or terminates the connection outright. A connection closed without any HTTP response leaves Cloudflare nothing to show, so it serves a 520. Bots were also solving the challenge and going straight to add-to-cart URLs, which is why the layer was so active on this store.

Root cause

  1. 1Visitor or bot
  2. 2Cloudflare edge
  3. 3SiteGround anti-bot layerConnection reset here
  4. 4Nginx and WordPressNever sees the request
With no response to pass on, Cloudflare shows the visitor error 520.

SiteGround's anti-bot layer was resetting connections from Cloudflare. WordPress, WooCommerce and the server's resources were not at fault. Because the resets happen before the web server, they never appear in the site's error logs. That is why the problem was so hard to pin down from either side.

SiteGround's support team confirmed in writing that its anti-bot layer either issues a verification challenge or terminates the connection, and that a close without HTTP headers is what Cloudflare reports as a 520.

The evidence

What we measuredResult
520s on static files under /wp-content/About 70% of all 520s
Image requests rejected at the edge (24 h)≈4,000 challenge responses and ≈1,500 520s
The same errors in the origin access logs (≈35,000 image requests)Zero: the requests never arrived
504 errors per day≈14,000, each answered in 13–17 ms, generated by Early Hints at the edge
520s with HTTP/2 to origin switched offContinued, so HTTP/2 was ruled out
Page 520s after the store's add-to-cart ruleDown from ≈300 an hour to under 30

What we recommended

Each change was small, reversible and measured before and after.

  1. Cache uploaded images at the edge

    A Cloudflare cache rule for /wp-content/uploads/ with a long edge TTL, plus Tiered Cache, so repeat image requests never pass through the anti-bot layer again.

  2. Filter bots at Cloudflare, not at the origin

    Block a crawler the existing rules missed, and apply a Managed Challenge to traffic from hosting networks, so bad traffic is stopped before it reaches the host's own defences.

  3. Turn off Early Hints

    This removed thousands of misleading 504s a day and made the real problem visible in the analytics.

  4. Ask the host the right questions

    We gave the store a short, evidence-backed message for SiteGround, asking for a 403 or 429 response instead of a reset, path exemptions, and logs for specific Cloudflare Ray IDs.

  5. Decide on HTTP/2 with data

    We left HTTP/2 to origin unchanged until a before-and-after test window had closed, so the decision would be based on measurement.

Results

  • 2.4×

    more product images served from Cloudflare's cache in the same time window, so far fewer requests reach the anti-bot layer at all.

  • ≈93%

    fewer 520s from a crawler the original rules had missed: from about 200 a day to 14.

  • ≈14,000

    misleading 504s a day removed by turning off Early Hints, which left a much clearer picture of the real problem.

  • 1

    written confirmation of the root cause from SiteGround, which gave the store a documented basis for its next decision.

What happened next

SiteGround declined to change its anti-bot behaviour or add path exemptions, describing it as standard platform behaviour, and endorsed the Cloudflare caching approach. Our follow-up analysis showed the remaining 520s were requests the anti-bot layer had refused, mostly from scraper traffic with one outdated browser version across many countries. The 520 rate from some countries the store doesn't sell to was about nine times higher than from its home market. We scoped a second phase: edge challenges for that traffic, an automatic retry for genuine visitors, and serving images from Cloudflare R2. The store chose to schedule it after the sales period.

Seeing Cloudflare 520 errors? Check these six things

  1. Split 520s by path

    If most are on images, CSS or JS, the cause is probably not PHP, the database or server capacity.

  2. Compare Cloudflare with your origin logs

    Count the same requests on both sides over the same period. Errors Cloudflare sees but your access logs don't are happening before your site.

  3. Ask what sits in front of your web server

    Managed hosts often run a WAF, anti-bot or captcha layer ahead of Nginx or Apache. Ask what it does when it refuses a request: does it send a status code, or reset the connection?

  4. Check how fast your 504s are

    504s answered in a few milliseconds, with Early Hints switched on, are usually generated at the edge, not by your server.

  5. Confirm static files are really cached

    Look at the cache status (HIT, MISS, BYPASS) of the failing requests. A BYPASS on an image usually means the origin, or something in front of it, refused it.

  6. Filter bots at Cloudflare first

    Stopping scraper and crawler traffic at the edge keeps it away from your host's own defences, which may handle it far less gracefully.

Frequently asked questions

What does a Cloudflare 520 error mean?

Cloudflare connected to your origin server, but the origin closed the connection or sent a response Cloudflare could not understand, often with no headers at all. It is a symptom, not a cause: the application, the web server, or a security layer in front of it can all produce it.

Can SiteGround's anti-bot protection cause Cloudflare 520 errors?

Yes. In this case SiteGround's anti-bot layer, which runs in front of its Nginx web server, was terminating connections from Cloudflare. SiteGround confirmed in writing that a close without HTTP headers appears in Cloudflare as a 520. Because it happens before the web server, the site's own logs show nothing wrong.

Why don't the 520 errors appear in my server's error logs?

When a security layer in front of the web server drops the request, the web server never sees it, so it writes nothing to its logs. A gap between Cloudflare's error count and the origin's own numbers is strong evidence that the problem sits between them.

Why does Cloudflare show 520 errors mostly on images?

Images make up most of the requests on a store's product and category pages, and every uncached image is a separate request to the origin. If a layer in front of the origin is refusing some requests, images are simply where most of the refusals land. Caching them at the edge with a long TTL removes most of that exposure.

Does HTTP/2 to origin cause Cloudflare 520 errors?

It can in some setups, but not in this one: the 520s continued at the same pattern with HTTP/2 to origin switched off. It is worth testing, but only with before-and-after measurements, not as a guess.

Why does Cloudflare report 504 errors that never reached my server?

With Early Hints enabled, Cloudflare can generate some 504s at the edge in a few milliseconds. In this case about 14,000 a day disappeared when Early Hints was turned off. A real origin timeout takes far longer.

How long does a Cloudflare 520 diagnosis take?

With read-only access to Cloudflare and the hosting control panel, we usually have evidence-backed findings within a few working days. Nothing is changed without your written approval, and any fix is quoted separately.

Client details have been withheld and figures rounded to protect confidentiality. Every number comes from the client's own Cloudflare analytics and the hosting account's access logs, read with the client's permission.

Errors you can't explain?

We run fixed-price root-cause diagnoses using your own Cloudflare and server data. We work read-only, nothing changes without your approval, and you get written findings you can take to your host.