Introducing Highlights: the context that matters

Cloudflare Error 1020 Access Denied: What It Means and How to Fix It

Cloudflare error 1020, "Access denied", means a firewall rule set by the site’s owner blocked the request. It is not an HTTP status code: Cloudflare usually serves the page with HTTP 403. The rule can match on IP address, country, user agent, request path, or other request properties, so the same site may work from one network and fail from another.

Code
1020
Name
Access Denied
Class
Cloudflare extension
Retry?
No, fix the cause first

What causes Cloudflare error 1020?

  • →A custom firewall rule that blocks a country, IP range, or ASN, such as cloud and datacenter networks.
  • →A rule that matches the User-Agent of HTTP libraries and known bots.
  • →A rule that blocks a path, such as an API or admin area.
  • →An IP address with a history of abuse, including shared proxy and VPN exits.

How do you fix Cloudflare error 1020 when web scraping?

  • →Treat 1020 as an explicit refusal from the site owner, not a technical glitch. Check robots.txt and the terms of service before going further.
  • →If you have a legitimate reason, contact the site owner with the Ray ID from the error page and ask for access or an API.
  • →If a regional rule is blocking a network you are allowed to use, a different exit country may be served normally. The guide to avoiding blocks when web scraping explains the difference between pacing your traffic and evading a ban.

How do you fix Cloudflare error 1020 on your own server?

  • →Search Security Events for the Ray ID or visitor IP to find the rule that matched.
  • →Narrow the rule, or allow the visitor in IP Access Rules if the block was a mistake.
  • →On Pro plans and above you can customize the block response, including its status code, per rule.

How do you handle Cloudflare error 1020 in a retry loop?

1020 is not in RETRYABLE, so raise_for_status() raises on the first response instead of spending retries on a request that will fail the same way. Fix the cause, then send the request again.

import random
import time

import requests

RETRYABLE = {408, 429, 500, 502, 503, 504, 520, 521, 522, 523, 524}


def fetch(url: str, max_attempts: int = 5) -> requests.Response:
    for attempt in range(max_attempts):
        try:
            response = requests.get(url, timeout=(10, 60))
        except requests.Timeout:
            time.sleep(2**attempt + random.uniform(0, 1))
            continue
        if response.status_code not in RETRYABLE:
            response.raise_for_status()
            return response
        retry_after = response.headers.get("Retry-After", "")
        backoff = 2**attempt + random.uniform(0, 1)
        time.sleep(min(int(retry_after) if retry_after.isdigit() else backoff, 60))
    raise RuntimeError(f"Gave up on {url} after {max_attempts} attempts")

How does Context.dev handle Cloudflare error 1020?

Context.dev runs every scrape in a browser with managed proxies and handles proxy selection and fetch retries for you. If the site still serves an anti-bot challenge or access wall, the output fails with WEBSITE_BLOCKED inside an HTTP 200 response, and a request where every output fails is not charged. Retrying later or from another sharedParams.country sometimes succeeds when the rule is regional.

See what the web scraping API does on every request, or read how to fix HTTP errors in web scraping for a longer walkthrough.

Frequently asked questions about Cloudflare error 1020

What does Cloudflare error 1020 mean?

A firewall rule written by the site’s owner matched your request and blocked it. Cloudflare enforces the rule; the owner chose it.

How do I fix error 1020 as a visitor?

Send the site owner a screenshot of the error, including the Ray ID. Changing networks can help if the rule targets your IP or region.

Is 1020 the same as a 403?

Close. A 1020 page is usually served with HTTP 403, but 1020 tells you specifically that a Cloudflare firewall rule caused it.

Which status codes are related to 1020?

Sources

Last reviewed

Ship an agent that actually knows things.

Free tier, 10-minute integration, and the same API powering agents at Mintlify, daily.dev, and Propane. No credit card to start.