(Created on )

Puppeteer: Blank page cannot have cookies

A cookie cannot target `about:blank`. This error can occur with both CDP and WebDriver BiDi.


A cookie cannot target about:blank. This error can occur with both CDP and WebDriver BiDi.

Error message

Blank page can not have cookie '{value}'

{value} is replaced by the value shown in your error message.

How this error happens

A new page begins at about:blank, which is not a cookie origin. Explicitly using that URL as a cookie target is rejected.

The snippets use a new Puppeteer page named page.

await page.setCookie({
    name: "session",
    value: "example",
    url: "about:blank",
});

How to fix

Target the actual HTTP or HTTPS site. Set the cookie for that URL before navigating if the first request needs it.

await page.setCookie({
    name: "session",
    value: "example",
    url: "https://example.com",
});

await page.goto(
    "https://example.com"
);

Things to keep in mind

Simply omitting url on a blank page may produce a missing-domain error instead. Use the site’s real URL; CDP and BiDi may format the cookie name with different quotation marks.

All Puppeteer errors

Keep Reading

Puppeteer Guides

All Guides →