How to launch Puppeteer in incognito mode?

When connecting to a browser instance using a WebSocket endpoint with puppeteer.connect({ browserWSEndpoint: '' }), you might want to open the browser directly in incognito mode. While Puppeteer allows you to create private sessions using:

const incognito = await browser.createIncognitoBrowserContext();

this incognito context still exists within the main browser instance. If you want a completely separate private session, you can instead launch Puppeteer with incognito mode enabled globally by adding launch arguments:

const browser = await puppeteer.launch({
  args: ['--incognito']
});

This ensures a private browsing environment right from the start without linking it to a shared session.

If you’re connecting via a WebSocket and just need an isolated private tab, you can do:

const incognito = await browser.createIncognitoBrowserContext(); const page = await incognito.newPage();

This keeps your session completely separate from the default browser context — no cookies, cache, or local storage leaks.

If your goal is to start Puppeteer entirely in incognito mode (not tied to the main context), launch it like this:

const browser = await puppeteer.launch({ args: [‘–incognito’] });

This makes every opened page private from the get-go — ideal for clean-slate testing.

Just a heads-up: using --incognito with puppeteer.connect() won’t automatically create an incognito window. You’ll still need to call createIncognitoBrowserContext() after connecting. The flag only works when launching a new browser instance with puppeteer.launch().