October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk3 min

How to Set a Browser User Data Directory in Puppeteer

Use Puppeteer’s userDataDir launch option to select Chrome’s profile directory, with writable-path guidance and fixes for common launch problems.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Set Puppeteer’s browser profile directory with the userDataDir option in the object passed to puppeteer.launch(). The path must be writable by the operating-system user that starts Chrome.

Set userDataDir when launching Puppeteer

Pass a string path as userDataDir in the launch options. This example uses an explicit profile directory and closes the browser even if navigation fails:

As an Amazon Associate I earn from qualifying purchases.

import puppeteer from 'puppeteer';

const browser = await puppeteer.launch({
  userDataDir: '/path/to/profile',
});

try {
  const page = await browser.newPage();
  await page.goto('https://example.com');
} finally {
  await browser.close();
}

Replace /path/to/profile with a directory appropriate for the machine or container running Chrome. In the current Puppeteer LaunchOptions reference (version 25.12.0 shown there), userDataDir is an optional string path: Puppeteer LaunchOptions.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose a writable path and understand profile persistence

Chrome must be able to write to the profile directory. Puppeteer’s troubleshooting guide explicitly notes that it needs a writable user data directory and gives /tmp/.puppeteer-profile as an example: Puppeteer troubleshooting.

Puppeteer creates a temporary profile under the operating system’s temporary directory by default. Setting an explicit path is useful when your deployment requires a known location. Whether that profile’s data remains available after the browser closes or an environment resets depends on the selected path and the deployment’s cleanup and volume lifecycle; an explicit path alone does not guarantee persistence.

In containers and read-only environments

Chrome writes profile, configuration, and cache files during startup. In a read-only container, point these locations to writable paths or mount writable volumes, and ensure the Chrome process owns or can write to them. Otherwise, Chrome may fail before Puppeteer connects. Check the profile path as well as other startup locations used by the browser.

Know when to use a browser context instead

userDataDir selects the user data directory for the launched browser. A BrowserContext instead provides storage isolation within a running browser: Puppeteer documents that cookies and local storage are not shared between contexts, and that each non-default Chrome context is incognito. Use a context when tasks need separate cookies or local storage during one browser run; use userDataDir when you need to choose the launched browser’s profile directory.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

See Puppeteer’s BrowserContext API for the context behavior.

Make sure Puppeteer has a browser to launch

The puppeteer package downloads a compatible Chrome for Testing browser. puppeteer-core does not download Chrome. If you use puppeteer-core or a manually managed browser, configure an explicit executablePath or a channel for an installation in a standard location as appropriate; userDataDir still sets the profile path. Refer to the Puppeteer installation guide.

Troubleshoot launch and profile errors

  • The profile option seems ignored: Confirm that userDataDir is inside the options object passed to puppeteer.launch(), not an option for newPage().
  • Chrome fails to start or connect: Check that the launching operating-system user can write to the profile directory. In containers, also verify write access to configuration and cache locations and mount writable volumes where needed.
  • No compatible browser is found: If you use puppeteer-core or a browser installed separately, supply the correct executablePath or channel.
  • You need separate task storage, not a chosen launch profile: Use browser contexts to isolate cookies and local storage within the running browser.
  • The process is left running after automation: Close it with await browser.close() when finished.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If your task is to capture a website rather than manage a Puppeteer profile, ScreenshotNeo returns a screenshot with one GET request. Its API can remove cookie or consent banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, failed loads, and cache hits are not billed. Its MCP server gives AI agents screenshot and PDF tools, and the free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000.

cURL:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp

Python:

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://example.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)

Node.js:

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://example.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

See the ScreenshotNeo API documentation for request options. Sign up for 1,000 free screenshots a month with no card.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
The SQL Programming Language: .
  • Used Book in Good Condition

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.