403 Forbidden by Cloudflare: WAF Rules and Bot Fight Mode

403 Forbidden by Cloudflare: WAF Rules and Bot Fight Mode

Written by

in

Lab-tested: Local WAF mock (Python 3.13.5) + Cloudflare primary docs · 2 Dec 2026 · Rule reproduced in our lab

Fix Box — Try this first (10 seconds)

If Cloudflare returns the 403, your origin server never saw the request. Open the Cloudflare dashboard and check Security Events for your IP and time. The event names the rule that blocked you.

Pause or adjust that one rule, then reload. Our 403 pillar guide separates Cloudflare blocks from origin blocks.

How to tell Cloudflare blocked you

A Cloudflare block page looks different from a server error page. It usually shows a Cloudflare Ray ID at the bottom.

That Ray ID is your receipt for the block.

The origin log is the second clue. If the request never appears in your server log, Cloudflare stopped it at the edge.

An origin 403 always leaves a log line behind.

Cause 1: A WAF custom rule

Custom WAF rules match fields like country, path, or user agent. A rule written for bots can easily catch real visitors.

The match happens before your server is involved.

Rules also stack in order. An early broad rule can block traffic a later rule meant to allow. The Security Events page shows which rule fired.

Cause 2: Bot Fight Mode

Bot Fight Mode challenges or blocks traffic that looks automated. It is designed for simple bot traffic on free plans.

Legitimate tools, feed readers, and uptime monitors can look automated too.

Cloudflare documents that Bot Fight Mode cannot be tuned per rule. On free plans it is essentially on or off.

That makes it a common surprise source of 403s.

Cause 3: Rate limiting and IP access rules

Rate limiting rules block IPs that request too fast. IP access rules block whole addresses or ranges outright. Both return 403 or a challenge, depending on configuration.

A shared office IP can inherit someone else’s block. Your own requests look innocent, but the IP history is not. Security Events will show the rule type.

Our lab test: a local WAF mock

We cannot ethically hammer a real Cloudflare account, so we built a local WAF mock. It implements the same two rule shapes: block a named bad user agent, and block an empty user agent on the login path.

The mock ran on our lab server on 2 Dec 2026.

A request with the blocked user agent returned 403. The log recorded the rule refusal verbatim:

2026/12/02 01:24:30 [error] access forbidden by rule, client: 127.0.0.1, server: lab403, request: "GET /index.html HTTP/1.1"

A request to the login path with an empty user agent also returned 403. A normal browser user agent returned 200 on the same URL.

The mock header X-Lab-WAF: mock-rule-1001 proves the edge layer, not the origin, made the decision.

This mirrors the real diagnostic: same URL, different client signals, different result. On real Cloudflare, Security Events plays the role our mock header plays here.

Step-by-step fix

Open your Cloudflare dashboard and go to Security, then Events. Filter by your IP address and the time of the block.

Note the rule name and the action taken.

If a custom rule fired, open that rule and narrow its match. Add an exception for your IP or path, or switch the action to log-only while you test.

Reload the page after each single change.

If Bot Fight Mode fired, decide whether you need it. Turning it off is the only tuning available on free plans. Paid plans offer finer bot controls instead.

If the block is an IP access rule, check who added it and why. Remove stale entries that catch shared IPs. Then confirm with the 403 Checker.

Not a Cloudflare block after all? The Nginx and Apache guide covers origin rules. WordPress sites should also check the WordPress guide.

What Did Not Work

Whitelisting our test IP at the origin changed nothing in the mock test. The edge mock blocked the request before the origin saw it.

Origin fixes cannot help when the edge decides first.

Changing the URL path also failed against the user-agent rule. The rule matched the client signal, not the path. Only changing the signal, or the rule, restored 200.

Prevention

Name every WAF rule with its purpose and owner. Start new rules in log-only mode for a few days. Review Security Events weekly for false positives.

FAQ

Frequently Asked Questions

How do I know Cloudflare, not my server, returned 403?

Look for a Ray ID on the error page. Then check your origin log for the same minute. No log line means the edge blocked it.

Can Bot Fight Mode block Googlebot?

Cloudflare states verified bots are handled separately, but misidentified crawlers can be caught. Check Security Events for the crawler’s IP. If it is blocked, review your bot settings.

Will pausing Cloudflare prove the cause?

Yes, pausing sends traffic straight to the origin. If the 403 disappears, the edge layer caused it. Remember to unpause after the test.

Sources and date

Lab test: 2 Dec 2026, local WAF mock on our SI machine (Python 3.13.5; rule shapes from Cloudflare primary documentation; no third-party Cloudflare account or public API was used).

Mock responses are labelled as mock in the lab output.

References

  • RFC 9110 §15.5.3 — 403 Forbidden: https://www.rfc-editor.org/rfc/rfc9110.html
  • MDN Web Docs — 403 Forbidden: https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/403
  • Cloudflare — WAF documentation: https://developers.cloudflare.com/waf/
  • Cloudflare — Bot Fight Mode: https://developers.cloudflare.com/bots/get-started/bot-fight-mode/

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *


More posts