Skip to content

wp-login.php challenge loop: locked out of your own WordPress by Cloudflare

You protected wp-login.php with a Cloudflare rule and now the challenge page loops — for you. Challenge versus block semantics, clearance cookies, IP allowlists, and a login defense that never locks out the admin.

You added a Cloudflare rule to protect wp-login.php, and now the person it reliably stops is you: the challenge page appears, you pass it, and it appears again — or worse, a hard 403 with no way through. Nothing is broken at WordPress; the edge rule is doing what it was told, and what it was told was too blunt. The way out is always available — the Cloudflare dashboard is not behind your own zone — and the durable fix is a rule stack that challenges strangers, skips your known IPs, and never uses Block where Managed Challenge belongs.

What’s happening

Two different actions get conflated in login protection. Block returns a 403, full stop — with a dynamic home IP or a travelling admin, a Block rule on wp-login.php is a self-lockout scheduled for later. Managed Challenge interposes a verification step; passing it sets a cf_clearance cookie that vouches for the browser for the Challenge Passage duration (Security > Settings, 30 minutes by default).

The loop appears when that clearance cannot be earned or kept:

  • The browser will not hold the cookie — aggressive privacy extensions, cookie-blocking profiles, or corporate proxies that strip Set-Cookie.
  • The visitor context keeps changing — a VPN or carrier network that rotates IPs invalidates clearance, so every few requests earn a fresh challenge.
  • Under Attack Mode is on zone-wide, layering an interstitial over everything, including the challenge flow you were already in.
  • Overlapping rules — your login rule challenges the GET, you pass, then a second rule (rate limiting, a country rule, a bot feature) fires on the POST of the credentials, which a browser mid-form-submit experiences as a loop or a swallowed login.

The POST detail matters generally: a challenge served on a form submission interrupts it, and the re-submission after clearance does not always survive, which reads as “the login page just reloads”.

What to check first

  • Can you reach the Cloudflare dashboard? (Yes — dash.cloudflare.com is not proxied by your zone. Start there, not at your origin.)
  • Security > Events filtered by your own IP: which rule fired, what action, how many times in the last hour.
  • Whether the loop follows a specific network — office fine, home VPN looping — which implicates clearance invalidation, not the rule itself.
  • Whether Under Attack Mode or a raised Security Level was left on after an incident.

How to verify

# What does the edge do with the login page?
curl -sI https://www.example.com/wp-login.php \
  | grep -iE '^HTTP/|cf-mitigated|cf-ray'

# Compare from an allowlisted network vs the failing one:
# 200 (or WordPress's own response) = no interception
# 403 + cf-mitigated: challenge = challenge flow
# 403 + cf-mitigated: block = hard block, no way to pass

In the browser, an endless loop shows the challenge page returning with a fresh cf-ray each time; devtools > Application > Cookies reveals whether cf_clearance is being set at all. In Security > Events, your IP appearing dozens of times with action “Managed Challenge” and no subsequent clean requests is the loop, written down.

The fix

  1. Regain access from the dashboard. Log in to Cloudflare directly, open Security > Events, identify the rule punishing your IP. If you need WordPress access this minute, temporarily set the rule to Log-nothing by disabling it — not deleting it — while you fix the design.
  2. Put a skip for trusted IPs above the challenge rule. Custom rules evaluate top-down. First rule: expression ip.src in {203.0.113.7 198.51.100.0/29}, action Skip (all remaining custom rules). Your office and VPN egress IPs sail through; order does the work.
  3. Rewrite the protection rule underneath it: http.request.uri.path eq "/wp-login.php" and not ip.src in {203.0.113.7 198.51.100.0/29} with action Managed Challenge — never Block. A challenge stops bots and lets a human client, contractor, or you-from-a-hotel pass.
  4. Raise Challenge Passage (Security > Settings) to a few hours so admins are not re-challenged mid-workday.
  5. Add a rate limit as the backstop for credential stuffing: one rule on POSTs to /wp-login.php, threshold in the range of 5 requests per minute per IP, action Managed Challenge or Block for a short period. Plan note: Free includes 1 rate limiting rule, Pro 2, Business 5 — spending the free one here is the classic move.
  6. No static IP at all? Then drop the skip rule and run challenge-for-everyone plus the rate limit, and put the real security in WordPress: strong passwords, two-factor authentication, application passwords for automation. Cloudflare Access can gate the login with identity instead of IPs, but this stack works without touching Zero Trust.

When this fix is wrong

  • No cf-mitigated header and no event for your IP: the block is at the origin — a security plugin’s lockout table, fail2ban, or .htaccess deny. Cloudflare rule surgery changes nothing.
  • The loop happens on every page, not just login: that is Under Attack Mode or Security Level, a zone conversation rather than a login-rule one.
  • A clean browser profile works fine: the problem is an extension or cookie policy on the affected machine, and the rule stack is healthy.

Common mistakes

  • Using Block on wp-login.php “for maximum security” from a dynamic IP — the lockout is a when, not an if.
  • Placing the allow/skip rule below the challenge rule and concluding skips are broken.
  • Allowlisting an entire country to fix one admin’s access.
  • Letting the office IP allowlist rot after an ISP change, then diagnosing a “Cloudflare outage”.
  • Grey-clouding the record to get back in and forgetting to re-enable the proxy afterward — the site keeps working, unprotected, and nobody notices for months.

Prevention

  • Write down the break-glass procedure: dashboard login path, the name of the login rule, which rule to disable.
  • Keep trusted IPs in one skip rule with a comment dating each entry; review quarterly.
  • Prefer Managed Challenge everywhere a human might legitimately appear; reserve Block for indisputable machine patterns documented in Cloudflare WAF rule patterns for WordPress.
  • Pair the login rule with sensible thresholds from rate limiting rules and thresholds, and keep the challenge mechanics reference handy in the Cloudflare WAF docs.

A login defense you cannot get through is not a defense — it is scheduled downtime for the one account that matters. Need Cloudflare stabilized in front of a WordPress or WooCommerce site that earns money? Stack Harbor runs that exact stack under Enterprise WordPress — book an infrastructure consult.