When Crawlee logs "Request blocked - received 403 status code." on a Cloudflare site, its session pool is doing what it was designed to do: 401, 403 and 429 count as blocks, the session is retired and the request is retried with another one. The block itself has one of three causes. Your HTTP crawler's fingerprint or IP looks automated. Cloudflare served a JavaScript challenge that CheerioCrawler and got-scraping cannot execute. Or a firewall rule (error 1020) refuses you outright.
Fix it in this order: confirm which case you are in, switch the HTTP client and proxies (got-scraping is now end-of-life), move challenge pages to PlaywrightCrawler with Camoufox and handleCloudflareChallenge, or replay a cf_clearance cookie from an HTTP crawler. Crawlee behaviour is quoted from the 3.x source and docs (crawlee 3.18.2), checked 2026-12-01.
Quick answer: what your Crawlee log means
Find the line you see in your logs, then jump to the matching step.
- Request blocked - received 403 status code.
- The session pool treats 401, 403 and 429 as blocks (blockedStatusCodes default). The session is retired and the request retried. Find out why it was blocked (step 1) instead of raising retries.
- Detected a session error, rotating session...
- A SessionError; it counts against maxSessionRotations (default 10), not maxRequestRetries (default 3). If every session fails, rotating more will not help; the fingerprint, IP or challenge is the issue.
- Request failed and reached maximum retries.
- All retries were blocked too. Same diagnosis. Check the cf-mitigated header on the 403.
- Cloudflare challenge failed, found selectors: ...
- retryOnBlocked found Cloudflare challenge markup after waiting. A browser crawler alone did not pass. Try Camoufox plus handleCloudflareChallenge, or a cf_clearance cookie.
- Detected Cloudflare challenge at <url>, trying to solve it.
- handleCloudflareChallenge (Crawlee 3.13.0+) is clicking the challenge. If it then throws "Blocked by Cloudflare when processing <url>", the page is a block, not a challenge.
- 403 "Sorry, you have been blocked" / Error 1020
- A firewall rule, nothing to solve. Change IP or region, or ask the site owner.
- Works for a while, then 429
- Rate limiting. Lower maxConcurrency and spread requests over a ProxyConfiguration.
- Error [ERR_REQUIRE_ESM] when requiring got-scraping
- got-scraping 4.x is ESM-only. Use import, or better, move to impit: got-scraping is end-of-life.
Log strings are quoted from the Crawlee 3.x source (basic-crawler, browser-crawler, playwright-utils, errors); defaults from the SessionPool API docs; got-scraping status from its README, checked 2026-12-01.
What Crawlee does when Cloudflare blocks you
Every Crawlee crawler runs on a session pool. By default (useSessionPool: true, persistCookiesPerSession: true) each session carries its own cookies and, with a ProxyConfiguration, its own proxy. When a response comes back with one of the blockedStatusCodes, which default to [401, 403, 429], BasicCrawler throws "Request blocked - received 403 status code.", retires that session and retries the request with another. Session errors count against maxSessionRotations (default 10), separately from maxRequestRetries (default 3).
That loop handles occasional bad IPs well. It does not change your fingerprint, and it cannot run JavaScript in an HTTP crawler: the Crawlee docs say HTTP-based crawlers "generally cannot execute client-side JavaScript". If every session gets the same 403, more rotation only burns proxies.
Step 1: see the 403 before Crawlee retires it
For a quick diagnosis, empty blockedStatusCodes so the 403 reaches your handler, and turn retries off. Cloudflare marks challenge pages with the cf-mitigated: challenge response header and a "Just a moment..." title; block pages (1020) and rate limits (429) look different and need different fixes. Restore the defaults afterwards.
import { CheerioCrawler } from 'crawlee';
const crawler = new CheerioCrawler({
// Let 401/403/429 reach the handler instead of
// "Request blocked - received 403 status code." (debugging only)
sessionPoolOptions: { blockedStatusCodes: [] },
maxRequestRetries: 0,
async requestHandler({ request, response, $, log }) {
const status = response.statusCode;
const mitigated = response.headers['cf-mitigated'];
const title = $('title').text();
log.info(request.url + ' status=' + status + ' cf-mitigated=' + mitigated + ' title=' + title);
if (mitigated === 'challenge' || title.includes('Just a moment')) {
log.warning('JS challenge: an HTTP crawler cannot pass it, see the browser or cf_clearance steps');
} else if ($('body').text().includes('1020')) {
log.warning('Firewall rule (1020): nothing to solve, change IP or ask the site owner');
} else if (status === 429) {
log.warning('Rate limited: lower maxConcurrency and spread over proxies');
}
},
});
await crawler.run(['https://target-site.com/']);Step 2: replace got-scraping and fix your proxies
got-scraping is Crawlee's default HTTP client in 3.x (GotScrapingHttpClient). Its README now opens with "got-scraping is EOL": it "will no longer receive updates or support", and Apify recommends impit for new projects. It still works (npm 4.2.2, October 2026), but browser-like headers and TLS settings that no longer change will look older every month. got-scraping issue #65, "got-scraping inefficient against Cloudflare", collected 52 comments before it was closed.
Crawlee ships ImpitHttpClient as the alternative (npm i @crawlee/impit-client); the docs show it with a browser option. Pair it with a ProxyConfiguration: Crawlee's "Avoid getting blocked" guide names IP addresses and browser fingerprints as the two main causes of blocks, and datacenter IPs are challenged far more often than residential ones. Lower maxConcurrency on sites that rate-limit.
// npm i @crawlee/impit-client
// got-scraping is end-of-life; impit is Apify's recommended replacement.
import { CheerioCrawler, ProxyConfiguration } from 'crawlee';
import { ImpitHttpClient } from '@crawlee/impit-client';
const crawler = new CheerioCrawler({
httpClient: new ImpitHttpClient({
browser: 'firefox', // browser profile impit imitates (example from the Crawlee docs)
}),
proxyConfiguration: new ProxyConfiguration({
proxyUrls: ['http://user:pass@proxy-1.example.com:8000', 'http://user:pass@proxy-2.example.com:8000'],
}),
maxConcurrency: 5,
async requestHandler({ request, $, log }) {
log.info(request.url + ' ' + $('title').text());
},
});
await crawler.run(['https://target-site.com/']);Step 3: challenge pages need PlaywrightCrawler
If step 1 showed cf-mitigated: challenge, no HTTP client fixes it. Move those URLs to a browser crawler. Crawlee's own recommendation for Cloudflare, in its anti-blocking guide, is PlaywrightCrawler with Camoufox (a Firefox build aimed at scraping) and the handleCloudflareChallenge helper in a post-navigation hook. Disable Crawlee's own fingerprint injection (useFingerprints: false) so it does not conflict with Camoufox's.
handleCloudflareChallenge was added in Crawlee 3.13.0 (March 2025) and updated for new Cloudflare markup in 3.18.0 and 3.18.1, so upgrade if you are on an older 3.x. Its source notes that it "works best with camoufox". It detects the challenge, clicks the checkbox, then waits (sleepSecs, default 10) for the page to load. Options let you override the click position and the challenge and block detection.
// npm i crawlee playwright camoufox-js (camoufox-js needs Node 22+)
// Verbatim pattern from Crawlee's "Avoid getting blocked" guide.
import { PlaywrightCrawler } from 'crawlee';
import { launchOptions } from 'camoufox-js';
import { firefox } from 'playwright';
const crawler = new PlaywrightCrawler({
postNavigationHooks: [
async ({ handleCloudflareChallenge }) => {
await handleCloudflareChallenge(); // Crawlee 3.13.0+
},
],
browserPoolOptions: {
// Disable the default fingerprint spoofing to avoid conflicts with Camoufox.
useFingerprints: false,
},
launchContext: {
launcher: firefox,
launchOptions: await launchOptions({ headless: true }),
},
async requestHandler({ page, log }) {
log.info(await page.title());
},
});
await crawler.run(['https://target-site.com/']);retryOnBlocked, fingerprints and other knobs
- retryOnBlocked: true (default false) retries pages that look like Cloudflare or Google rate-limit pages. In browser crawlers it waits about 5 seconds on a Cloudflare 403 before failing with "Cloudflare challenge failed, found selectors: ...". Do not combine it with custom blockedStatusCodes: Crawlee warns that "the 'retryOnBlocked' feature might not work as expected".
- Fingerprints: with Chromium or stock Firefox, keep browserPoolOptions.useFingerprints on (the default) and narrow fingerprintOptions to one realistic browser and OS instead of random mixes.
- Known rough edges: crawlee issues #3124 and #3629 ("handleCloudflareChallenge not working as intended", closed June 2026) and #2027 (status still 403 after retryOnBlocked passed) are worth reading if your symptoms match.
- Version check: crawlee 3.18.2 is the current 3.x release; v4 is in release candidates and moves some blocking logic, so pin a version. Crawlee for Python (1.11.5) has its own API; the code here is JavaScript.
Step 4: replay cf_clearance from an HTTP crawler
Browsers are expensive per page. The usual compromise is to earn cf_clearance once per IP, then fetch with CheerioCrawler while sending that cookie, the exact User-Agent that earned it, and the same proxy. The cf_clearance cookie guide explains what the cookie is bound to and how long it lasts.
The example gets the cookie from NSLSolver's challenge type, which runs server-side with no browser on your machines, and injects it in a pre-navigation hook. One honest caveat: the clearance is issued for an iPhone Safari browser, while got-scraping and impit present Chrome- or Firefox-style TLS. If a site checks that pairing and challenges again, fetch those pages with a client that has a Safari iOS fingerprint (curl_cffi's safari_ios target, see curl_cffi Cloudflare 403) or keep them on the browser crawler.
// Node 18+ (built-in fetch). Get cf_clearance once, replay it from CheerioCrawler.
import { CheerioCrawler, ProxyConfiguration } from 'crawlee';
const TARGET = 'https://target-site.com/';
const PROXY = 'http://user:pass@sticky-proxy.example.com:8080'; // same exit IP for solve AND replay
const res = await fetch('https://api.nslsolver.com/solve', {
method: 'POST',
headers: { 'X-API-Key': process.env.NSLSOLVER_API_KEY, 'Content-Type': 'application/json' },
body: JSON.stringify({
type: 'challenge',
url: TARGET,
site_key: '0x4AAAAAAA...', // the challenge widget id
proxy: PROXY, // required for challenge
// no user_agent: the clearance is issued for an iPhone Safari browser
}),
});
const data = await res.json();
if (!res.ok || !data.success) throw new Error(res.status + ' ' + JSON.stringify(data));
const cookieHeader = Object.entries(data.cookies).map(([k, v]) => k + '=' + v).join('; ');
const crawler = new CheerioCrawler({
proxyConfiguration: new ProxyConfiguration({ proxyUrls: [PROXY] }),
persistCookiesPerSession: false, // we send the clearance cookie ourselves
preNavigationHooks: [
async (_ctx, gotOptions) => {
gotOptions.headers = {
...gotOptions.headers,
'user-agent': data.user_agent, // the UA the clearance was issued for
cookie: cookieHeader, // includes cf_clearance
};
},
],
async requestHandler({ request, response, log }) {
log.info(request.url + ' ' + response.statusCode + ' ' + response.headers['cf-mitigated']);
},
});
await crawler.run([TARGET]);When a solver API beats more tuning
Use an API when challenges are the bottleneck: every session gets cf-mitigated: challenge, you crawl many Cloudflare sites, or running Camoufox per worker costs more than the data is worth. NSLSolver's Cloudflare Challenge solver returns cf_clearance and the user_agent in about 3.3 seconds on average for $1.00 per 1,000. For forms protected by a Turnstile widget, the Turnstile solver returns a token in about 250 ms for $0.80 per 1,000. Only successful solves are billed, and new accounts get free credit with Google, Gmail or Proton sign-up. A 1020 firewall block cannot be solved by anyone. Only crawl sites you own or are authorised to access.
Related guides
- Cloudflare Challenge solver API: cf_clearance plus the user_agent to replay.
- Scrapy Cloudflare 403: the same problem in Python's Scrapy.
- Camoufox not working: when the browser Crawlee recommends still gets challenged.
- Playwright stealth not working: why stock Playwright is detectable.
- Open-source CAPTCHA solvers in 2026: the wider map of open-source tools.
Sources (checked 2026-12-01)
- Crawlee docs: Avoid getting blocked (Camoufox + handleCloudflareChallenge)
- Crawlee docs: HTTP clients (GotScrapingHttpClient, ImpitHttpClient)
- Crawlee API: SessionPoolOptions (blockedStatusCodes)
- Crawlee docs: proxy management
- Crawlee changelog (3.x branch)
- GitHub: apify/got-scraping (EOL notice)
- got-scraping issue #65: inefficient against Cloudflare
- Crawlee issue #3629: handleCloudflareChallenge not working as intended
- Crawlee issue #2027: status 403 after retryOnBlocked
- npm: crawlee