Puppeteer: Cannot specify both blocklist and allowlist
Puppeteer launch or connect options cannot specify both a URL blocklist and a URL allowlist.
Puppeteer launch or connect options cannot specify both a URL blocklist and a URL allowlist.
Error message
Cannot specify both blocklist and allowlist
How this error happens
URL restrictions use one policy: either explicitly allow selected destinations or block selected destinations. Supplying both is rejected during connect or launch.
The snippets use the imported puppeteer instance and an already-running Chrome/CDP endpoint.
await puppeteer.connect({
browserURL: "http://127.0.0.1:9222",
allowlist: [
"https://example.com/*",
],
blocklist: [
"https://blocked.example/*",
],
});
How to fix
Choose the policy your task requires. For a deny-by-default workflow, keep only the allowlist.
const browser = await puppeteer.connect({
browserURL: "http://127.0.0.1:9222",
allowlist: [
"https://example.com/*",
],
});
Things to keep in mind
The same restriction applies to puppeteer.launch. Launch may use “blockList” and “allowList” capitalization in its message. Removing an allowlist in favor of a blocklist changes the security policy.