By Rajesh Kannan, Co-Founder & CTO, Gramosoft · Last updated: · Error definitions checked against Cloudflare's own documentation on November 30, 2026
Cloudflare error 1020 "Access denied" means a security rule the site owner set up matched your request and blocked it. It isn't a rate limit like Cloudflare error 1015, so waiting won't clear it. This guide starts with the GcrawlAI route, then shows how to read the block, find the rule that fired and fix it, with code. For the wider toolkit to bypass Cloudflare, see our main guide.
TL;DR
- What it is: Cloudflare's docs define 1020 as a block by a security feature the site owner configured, returned as HTTP 403. A common source is API Shield schema or JWT validation on API endpoints.
- Lookalikes: WAF custom and managed rules now show "Sorry, you have been blocked", not 1020. Errors 1005, 1009, 1010 and 1015 each mean something else, and each has its own fix.
- Read before you fix: log the status, the
cf-rayheader and the error code. Ask forapplication/problem+jsonand Cloudflare returns the error as JSON. - GcrawlAI loads the page in a real browser through a residential IP in the site's market, as one request, and failed requests are never charged.
How do I fix Cloudflare error 1020 when scraping? Work out which rule fired. If it blocks your network, use a residential IP in the site's country. If it blocks your client, send real browser headers or use a real browser. If it guards an API endpoint, load the page the site's front end uses instead. GcrawlAI covers the first two in one request.
Fix Cloudflare error 1020 with GcrawlAI
Most 1020 and WAF blocks key on where a request comes from and what sends it. GcrawlAI changes both: each page loads in a real browser, through a residential IP in the country you choose, with stealth escalation when a challenge appears. Rendering, proxies and retries count as one request, and failed requests are never charged.
The call below fetches a Cloudflare-protected category page as HTML and Markdown from a US residential IP. It checks the content before you store anything, because a 200 can still carry a block page. Point base_url at your own server to run the same code on the self-hosted core.
# gcrawlai_scrape.py
# pip install gcrawl-sdk
"""Fetch a Cloudflare-protected page through GcrawlAI: a real browser, a residential IP in the
site's market, and stealth escalation when a challenge appears, all in one request."""
import os
from gcrawl_sdk import GcrawlClient, ScrapeOptions
gc = GcrawlClient(api_key=os.getenv("GCRAWL_API_KEY", "gc-YOUR_API_KEY"))
# Self-hosted core: GcrawlClient(api_key=..., base_url="http://localhost:8000")
page = gc.scrape(
url="https://shop.example.com/category/laptops",
options=ScrapeOptions(html_enabled=True, markdown_enabled=True, proxy_geo="US"),
wait=True,
)
html = page.html or ""
# A 200 isn't proof: check the content you came for before you store it.
if "Error 1020" in html or "Sorry, you have been blocked" in html:
print("still blocked: this rule needs a different request, not a different identity")
else:
print(len(html), "chars of HTML,", len(page.markdown or ""), "chars of Markdown")
- Network fixes built in: rotating residential IPs with country targeting, so ASN, IP and country rules see an ordinary visitor from the site's market.
- Client fixes built in: a real browser, so the User-Agent, client hints, TLS handshake and HTTP/2 settings agree, and JavaScript challenges run as they do for people.
- One request per page: JavaScript rendering, proxies, anti-bot handling for Cloudflare, DataDome, Akamai and PerimeterX, and CAPTCHA handling, with HTML, Markdown or screenshots back.
- Scrape, crawl, map and search: single pages, whole sites, site maps and the Search API, with sync calls or async batch jobs and webhooks.
- How you connect: the managed Cloud API, the Python SDK, an MCP server for AI agents, the Playground and docs, or the MIT-licensed core on your own servers.
- Billing: 50 free requests a month with no card, then $0.67 to $9.67 per 1,000 requests, and blocked pages, CAPTCHAs, timeouts and server errors are never billed.
Where it falls short: no service can change the site owner's rules. If a 1020 comes from API Shield because your direct API call lacks a valid token or breaks the schema, a new IP won't fix that call; load the page the site's own front end uses instead. There's no prompt-driven browsing agent for clicks and logins, the ecosystem is younger, and self-hosting means bringing your own proxy accounts.
"A 1020 is a decision someone made about your traffic. Find out which rule made it before you change anything, because the fix for a blocked network and the fix for a rejected API call have nothing in common."
Rajesh Kannan, Co-Founder & CTO at Gramosoft
What Cloudflare error 1020 means in 2027
Cloudflare's own documentation now defines 1020 narrowly: a security feature the site owner configured blocked the request with an HTTP 403. The usual cause is a Block rule with no custom response, such as API Shield schema or JWT validation. Requests blocked by WAF custom or managed rules get a different page.
That matters because many guides still say "1020 means you broke a firewall rule". The Error 1020 page in Cloudflare's docs says requests blocked by WAF custom rules or WAF managed rules don't get a 1020; they get the WAF block response, the page that reads "Sorry, you have been blocked". Both are deliberate decisions by the site owner, both come back as 403, and neither fades with time. A plain 403 Forbidden with no Cloudflare marks is a third thing: the origin server refused you.
| What you see | Status | What blocked you | First fix |
|---|---|---|---|
| Error 1020: Access denied | 403 | A security feature's Block rule (often API Shield on an API path) | Fix the request shape, or load the page instead of the endpoint |
| "Sorry, you have been blocked" | 403 | A WAF custom or managed rule | Find the rule: network, client or path |
| Error 1005 | 403 | Your network's ASN is banned | Residential IP in the site's country |
| Error 1006, 1007, 1008, 1106 | 403 | Your IP address is banned | New IP, slower pace |
| Error 1009 | 403 | Your country or region is banned | Exit IP in an allowed country |
| Error 1010 | 403 | Browser Integrity Check rejected your client | Real browser headers or a real browser |
| Error 1015 | 429 | A rate limiting rule | Wait for Retry-After, then slow down |
| "Just a moment..." | 403 | A managed or JavaScript challenge | A real browser that runs it |
The codes come from Cloudflare's pages for 1005, 1006 to 1008 and 1010. For 1015, our 429 Too Many Requests guide covers backoff in depth.
Read the block before you change anything
A blocked response tells you more than its status code. Cloudflare puts the 1xxx code in the page body and a Ray ID in the cf-ray header. Since March 2026 it also returns the error as structured JSON if you ask for it, with the code, Ray ID and whether a retry can help.
Cloudflare's changelog says its 1xxx errors return RFC 9457 problem details when a client sends Accept: application/json or application/problem+json, with fields such as error_code, ray_id, retryable and owner_action_required. Retryable errors also send a Retry-After header. Challenge pages carry cf-mitigated: challenge, which Cloudflare's challenge docs call the reliable way to spot them. The script below reads all of these and names the block.
# cf_block_check.py
# pip install requests
"""Which Cloudflare block did this request hit? Read-only: one request, plus one more for details if blocked.
Cloudflare's 1xxx errors return RFC 9457 JSON when the client asks for it (Accept: application/problem+json),
with error_code, ray_id and retryable fields. Older or customised pages only give HTML, so both are handled.
"""
import json
import re
import sys
import requests
BROWSER_HEADERS = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"Accept-Language": "en-US,en;q=0.9",
}
ACTIONS = {
"1020": "A security feature's Block rule (often API Shield schema or JWT validation). Fix the request shape: "
"path, method, body, token. Or load the page the site's own front end uses instead of the endpoint.",
"waf_block": "WAF custom or managed rule ('Sorry, you have been blocked'). Isolate it: network (IP, ASN, country), "
"client (User-Agent, headers, TLS) or path.",
"1005": "The site banned your network (ASN). Change exit network: residential IP in the site's country.",
"1006-1008": "This IP address is banned. Change IP; slow down so the new one isn't banned too.",
"1009": "Your country or region is banned. Use an exit IP in an allowed country.",
"1010": "Browser Integrity Check rejected your client's signature. Send real browser headers or use a real browser.",
"1015": "Rate limited. Wait for Retry-After, then send fewer requests per minute.",
"challenge": "Managed or JavaScript challenge ('Just a moment...'). Needs a real browser that runs the challenge.",
"origin_403": "403 without Cloudflare marks: the origin server refused you. Not a Cloudflare rule.",
"ok": "Not blocked.",
}
def classify(status, headers, body):
"""Name the block from status, headers and body. Works on HTML pages and RFC 9457 JSON."""
h = {k.lower(): v for k, v in headers.items()}
via_cf = "cf-ray" in h or h.get("server", "").lower() == "cloudflare"
info = {"status": status, "ray_id": h.get("cf-ray"), "retry_after": h.get("retry-after")}
if "json" in h.get("content-type", ""):
try:
data = json.loads(body)
except ValueError:
data = {}
if data.get("error_code"):
code = str(data["error_code"])
info.update(ray_id=data.get("ray_id") or info["ray_id"], retryable=data.get("retryable"))
kind = "1006-1008" if code in ("1006", "1007", "1008", "1106") else code
return dict(info, kind=kind, detail=data.get("title"), action=ACTIONS.get(kind, "See Cloudflare docs for " + code))
text = body[:20000] if status >= 400 else "" # a 200 page may mention these words in its content
m = re.search(r"Error\s*(?:code:?\s*)?(10\d\d|1106)\b", text)
if h.get("cf-mitigated") == "challenge" or "Just a moment" in text:
kind = "challenge"
elif m:
code = m.group(1)
kind = "1006-1008" if code in ("1006", "1007", "1008", "1106") else code
elif "Sorry, you have been blocked" in text:
kind = "waf_block"
elif status == 403 and not via_cf:
kind = "origin_403"
elif status < 400:
kind = "ok"
else:
kind = f"http_{status}"
return dict(info, kind=kind, action=ACTIONS.get(kind, "Unrecognised: log the body and the Ray ID."))
def probe(url, headers=BROWSER_HEADERS, session=requests):
r = session.get(url, headers=headers, timeout=20)
result = classify(r.status_code, r.headers, r.text)
if result["kind"] not in ("ok", "origin_403"):
# Ask Cloudflare for the structured version of the same error (works for 1xxx errors).
j = session.get(url, headers={**headers, "Accept": "application/problem+json"}, timeout=20)
details = classify(j.status_code, j.headers, j.text)
if "retryable" in details:
result = details
return result
if __name__ == "__main__":
for k, v in probe(sys.argv[1] if len(sys.argv) > 1 else "https://example.com/").items():
print(f"{k:<12} {v}")
It sends one request with browser headers and, only if that's blocked, one more asking for the JSON version, so it doesn't add load to the site. We checked the logic offline against canned pages shaped like Cloudflare's, not against live sites:
# demo_output.txt (printed output) classify(): 1020 page -> 1020 ray=8f2a1c3b9d4e5f60-BOM retry_after=None WAF block page -> waf_block ray=8f2a1c3b9d4e5f60-BOM retry_after=None 1010 page -> 1010 ray=8f2a1c3b9d4e5f60-BOM retry_after=None challenge -> challenge ray=8f2a1c3b9d4e5f60-BOM retry_after=None 1015 JSON -> 1015 ray=8f2a1c3b9d4e5f61 retry_after=30 origin 403 -> origin_403 ray=None retry_after=None normal page -> ok ray=8f2a1c3b9d4e5f60-BOM retry_after=None probe() on a 1020: kind=1020 retryable=False ray=8f2a1c3b9d4e5f62 requests=2 fetch_html(): normal page -> direct (16 chars) WAF block page -> gcrawlai after waf_block (Ray ID 8f2a1c3b9d4e5f60-BOM) (2016 chars) 1020 page -> gcrawlai after 1020 (Ray ID 8f2a1c3b9d4e5f60-BOM) (2016 chars) origin 403 -> origin_403: not a Cloudflare rule, check the URL or the origin (0 chars)
Keep the Ray ID and the UTC time with every failed request. They're what the site owner needs if you ask to be allowed, and a log of block types shows the pattern quickly: a run of 1015s means pace, 1005s mean the network, and block pages on one path only mean a path rule.
Find the rule that fired in five requests
A 1020 or WAF block is deterministic: some attribute of your request matched a rule. Don't throw a full stealth setup at it. Change one thing at a time, keep the request count tiny, and stop as soon as the answer is clear. Five requests are usually enough to tell which attribute it was.
- Same URL, normal browser, same network. If your browser is blocked too, the rule matches your IP, ASN or country. If it loads, the rule matches your client.
- Same script, different network. Try your office connection instead of a cloud server, or a proxy in the site's country. A change here confirms a network rule. A script that works on a laptop and fails from a cloud server is almost always an ASN rule.
- Same script, real browser headers. Send a current Chrome User-Agent with matching Accept and Accept-Language headers. If that clears it, the rule keyed on your client's signature; our user agents for web scraping guide lists current strings.
- Same client, different path. If the page loads but
/api/searchreturns 1020, it's an endpoint rule such as API Shield. The site's front end sends a token or body shape your script doesn't. - Same everything, slower. If blocks only start after a burst, it's rate limiting, so treat it like 1015.
If headers didn't help but a real browser does, the rule is reading signals below the headers, such as the TLS handshake. JA3 and JA4 TLS Fingerprints Explained shows how Python's default handshake gives scrapers away.
How to fix Cloudflare error 1020, cause by cause
Once you know which attribute the rule matched, the fix is usually one change. Network rules need a different exit, client rules need a browser identity that holds together, and endpoint rules need the request the site expects. Rate limits need patience. GcrawlAI handles the first two in one request.
| The rule matched | Fix it yourself | Where GcrawlAI fits |
|---|---|---|
| Cloud or datacenter ASN | Residential or ISP IPs | Residential IPs on every request |
| Country | An exit IP in the site's market | proxy_geo sets the country |
| User-Agent or missing headers | A current browser header set | A real browser sends them |
| TLS or HTTP/2 signature | curl_cffi impersonation or a real browser | A real browser's handshake |
| JavaScript challenge | A headful or stealth browser | Stealth escalation when a challenge appears |
| API schema or token (API Shield) | Send the token and body the front end sends | Render the page; its scripts call the API |
| Rate limit (1015 or 429) | Retry-After, backoff, fewer requests at once | Pace your jobs; GcrawlAI doesn't bill blocked requests |
Change the network. Datacenter and cloud IP ranges are the usual target, because owners can block a whole ASN or country in one rule. Residential IPs in the site's own country look like its customers. Our guide to residential vs datacenter proxies explains rotation and sticky sessions.
Make the client consistent. A Chrome User-Agent on Python's default handshake is a mismatch rules can catch. Either send everything a browser sends, using an impersonation library for the handshake, or use a real browser. Don't rotate User-Agents faster than IPs; a single visitor changing browsers every request looks stranger than one that never changes.
Respect the endpoint. API Shield checks that API calls match the site's schema and carry valid tokens. Copying a URL from DevTools without its token will keep failing. Load the page instead, or find the data in the page's HTML; hidden API scraping covers when calling the API directly is the better route.
Put it together and your scraper only pays for the expensive route when the cheap one is blocked. This version tries a direct request, waits on a rate limit, stops on an origin error, and sends rule-based blocks through GcrawlAI:
# fetch_with_gcrawlai.py
# pip install gcrawl-sdk requests
"""Try the cheap request first. When Cloudflare blocks it with a rule a browser identity can pass,
fetch the page through GcrawlAI instead. Rate limits and origin errors are handled differently."""
import os
import time
import requests
from gcrawl_sdk import GcrawlClient, ScrapeOptions
from cf_block_check import BROWSER_HEADERS, classify
gc = GcrawlClient(api_key=os.getenv("GCRAWL_API_KEY", "gc-YOUR_API_KEY"))
SEND_TO_GCRAWLAI = {"1020", "waf_block", "1005", "1006-1008", "1009", "1010", "challenge"}
def fetch_html(url, geo="US", session=requests, client=gc):
r = session.get(url, headers=BROWSER_HEADERS, timeout=20)
block = classify(r.status_code, r.headers, r.text)
if block["kind"] == "ok":
return r.text, "direct"
if block["kind"] == "1015":
time.sleep(int(block.get("retry_after") or 30)) # a rate limit: wait, don't switch routes
return None, "rate limited: retry later"
if block["kind"] not in SEND_TO_GCRAWLAI:
return None, f"{block['kind']}: not a Cloudflare rule, check the URL or the origin"
# A real browser through a residential IP in the site's market; the page's own scripts send
# whatever tokens its API endpoints expect. Failed requests aren't charged.
page = client.scrape(url, options=ScrapeOptions(html_enabled=True, proxy_geo=geo), wait=True)
return page.html, f"gcrawlai after {block['kind']} (Ray ID {block['ray_id']})"
if __name__ == "__main__":
html, route = fetch_html("https://example.com/")
print(route, len(html or ""), "chars")
"Most teams we talk to reach for a bigger proxy pool first. Half the time the block was on the path, not the IP, and the fix was loading the page the way a visitor does."
Rajesh Kannan, Co-Founder & CTO at Gramosoft
When to stop and contact the site owner
A 1020 is the site owner saying no to a kind of traffic. If the data is behind a login, covered by terms you've accepted, or available through an official API or feed, use that route. If you have a legitimate reason to collect public pages, sending the owner your Ray IDs is often the fastest fix.
Cloudflare's resolution for 1020 is exactly that: send the owner the error, and they look up the Ray ID in their Security Events log. Many owners will allow a known IP or point you to a feed. Scrape only public pages, follow robots.txt and rate limits, and keep personal data out unless you have a lawful basis. How to check if a website allows scraping walks through robots.txt and terms, and this isn't legal advice.
Frequently asked questions
What does Cloudflare error 1020 Access denied mean?
It means a security feature the website owner configured on Cloudflare blocked your request, returned as HTTP 403. Cloudflare's docs name API Shield schema and JWT validation as examples. It's a deliberate rule, not an outage or a rate limit, so retrying the same request won't help. GcrawlAI helps when the rule targets your network or client.
Is error 1020 the same as "Sorry, you have been blocked"?
No, though both are 403s chosen by the site owner. Cloudflare's docs say requests blocked by WAF custom or managed rules get the WAF block page, "Sorry, you have been blocked", instead of 1020. The diagnosis is the same: work out whether the rule matched your network, your client, the path or your request rate.
Does a VPN or proxy fix Cloudflare error 1020?
Only when the rule matches your IP, ASN or country. A residential IP in the site's market fixes those. It won't help when the rule matches your client's signature or an API call missing its token. Test with a browser on the same network first. GcrawlAI combines residential IPs with a real browser in one request.
How long does Cloudflare error 1020 last?
As long as the rule stays in place and your request matches it. Unlike error 1015, a rate limit that clears after a wait, 1020 has no timer and Cloudflare doesn't send a Retry-After header for it. Change whatever the rule matched, or ask the site owner to review it using the Ray ID.
Why do I get error 1020 on a cloud server but not on my laptop?
Almost always because the site blocks your cloud provider's network. Owners can block a whole ASN or country with one rule, and datacenter ranges are the usual target. Run the scraper through residential IPs in the site's country, or use GcrawlAI, which sends every request through a residential IP and a real browser.
Can I see why Cloudflare blocked me?
Partly. The page shows the error code and a Ray ID, and the cf-ray header carries the Ray ID. If you request application/problem+json, Cloudflare returns the error as JSON with fields such as error_code and retryable. Only the site owner can see which rule fired, in their Security Events log.
Is GcrawlAI open source, and what does it cost?
Yes. The core is MIT-licensed and self-hostable, alongside a managed Cloud API, Python SDK and MCP server. The free plan has 50 requests a month with no card, and paid plans run from $0.67 to $9.67 per 1,000 requests. Rendering and proxies are included in each request, and failed requests are never charged.
Related guides
- How to Bypass Cloudflare When Web Scraping (2026)
- 429 Too Many Requests: How to Fix It When Web Scraping
- How to Fix 403 Forbidden Errors in Python Requests (2026)
- How Websites Detect Scrapers: 13 Signals Anti-Bot Systems Check
- JA3 and JA4 TLS Fingerprints Explained (2026)
- Residential vs Datacenter Proxies, and How IP Rotation Works (2026 Guide)
- 10 Best User Agents for Web Scraping in 2026: Current Strings, Matching Headers and Rotation
- Web Scraping Without Getting Blocked: The 2026 Playbook
- How to Scrape AWS WAF-Protected Websites
- Fix 405 Method Not Allowed and 500 Errors in Web Scraping