Repository navigation
Description
Version
1.64.1 (latest). The relevant code is unchanged on main (df99ada).
Steps to reproduce
On Linux, chromium.connectOverCDP('chrome') (and chrome-beta, msedge, ...) finds the running browser by reading DevToolsActivePort from a hardcoded os.homedir()/.config/<product> directory. Chromium resolves its default user data dir from $CHROME_CONFIG_HOME, then $XDG_CONFIG_HOME, then ~/.config (docs/user_data_dir.md), so when either variable is set Chrome writes the file somewhere Playwright never looks.
Chrome 136+ refuses --remote-debugging-port on the default data dir, and $XDG_CONFIG_HOME/google-chrome counts as the default dir. To emulate "Chrome running with remote debugging enabled in its default dir" in a script, the repro below points Chrome at that directory through a symlink:
export XDG_CONFIG_HOME=/tmp/xdg
mkdir -p $XDG_CONFIG_HOME/real
ln -s $XDG_CONFIG_HOME/real $XDG_CONFIG_HOME/google-chrome # the dir Chrome would use by default
google-chrome --headless=new --remote-debugging-port=0 --user-data-dir=$XDG_CONFIG_HOME/real about:blank &
cat $XDG_CONFIG_HOME/google-chrome/DevToolsActivePort # Chrome did write it, here// repro.js
const { chromium } = require('playwright-core');
(async () => {
const browser = await chromium.connectOverCDP('chrome');
console.log('connected, contexts:', browser.contexts().length);
await browser.close();
})().catch(e => { console.error(e.message); process.exit(1); });node repro.jsExpected behavior
Playwright looks for DevToolsActivePort in the same directory Chrome uses, so it honors CHROME_CONFIG_HOME and XDG_CONFIG_HOME the way Chrome does, and connects.
Actual behavior
browserType.connectOverCDP: Could not connect to chrome: DevToolsActivePort file not found at /home/<user>/.config/google-chrome/DevToolsActivePort.
Make sure chrome is running with remote debugging enabled. Navigate to
chrome://inspect/#remote-debugging
and check "Allow remote debugging for this browser instance".
The hint is misleading here: remote debugging is enabled, and the file exists in the directory Chrome actually uses.
Additional context
The Linux user data dirs are hardcoded as path.join(os.homedir(), '.config', '<product>') in two tables that are kept in sync by hand:
packages/utils/chromiumChannels.ts(channelToDefaultUserDataDir), used byresolveChannelEndpointinpackages/playwright-core/src/server/chromium/chromium.tsand by the MCP extension context factorypackages/playwright-core/src/tools/cli-client/channelSessions.ts(channelToUserDataDir), used forplaywright-cli attach
Proposed fix, applied to both tables:
// Chromium resolves the Linux config dir from $CHROME_CONFIG_HOME, then $XDG_CONFIG_HOME, then ~/.config.
const linuxConfigHome = process.env.CHROME_CONFIG_HOME || process.env.XDG_CONFIG_HOME || path.join(os.homedir(), '.config');
// every 'linux' entry: path.join(os.homedir(), '.config', 'google-chrome') -> path.join(linuxConfigHome, 'google-chrome')Reading the right file is not enough to make the repro above connect, because of a second, related problem in resolveChannelEndpoint: it only reads line 1 of DevToolsActivePort (the port) and always builds ws://localhost:${port}/devtools/browser. With the file found, Chrome in --remote-debugging-port mode answers that URL with 404 Not Found, because it expects the path from line 2 (/devtools/browser/<uuid>). Using line 2 when present, and keeping the current path as the fallback, fixes it:
const [portLine, wsPathLine] = contents.trim().split('\n');
const port = parseInt(portLine, 10);
// ...
const endpoint = `ws://localhost:${port}${wsPathLine?.trim() || '/devtools/browser'}`;I built this against main (df99ada) and checked it:
repro.jsabove:1.64.1fails with the error shown; the patched build printsconnected, contexts: 1. The same works withCHROME_CONFIG_HOMEset instead ofXDG_CONFIG_HOME.- A new test in
tests/library/chromium/connect-over-cdp.spec.ts(launches a persistent context with--remote-debugging-port=0under$XDG_CONFIG_HOME/google-chromeand connects from a child process) fails without the change with the error above, and passes with it. npm run ctest -- connect-over-cdp: no new failures (CD-004fails onmainin my environment as well).
I would like to submit the PR for this myself. Please assign this issue to me before any automated fix is attempted. The branch and the test are ready, and I will not open the PR until the issue is assigned to me.
I searched the tracker for XDG_CONFIG_HOME, CHROME_CONFIG_HOME, DevToolsActivePort and connectOverCDP chrome channel; no existing issue covers this.
Environment
System:
OS: Linux 7.0 Ubuntu 24.04.5 LTS 24.04.5 LTS (Noble Numbat)
CPU: (24) x64 Intel(R) Core(TM) Ultra 9 275HX
Memory: 37.52 GB / 62.25 GB
Binaries:
Node: 22.23.4
npm: 9.2.0
npmPackages:
playwright-core: ^1.64.1 => 1.64.1
Browsers:
Google Chrome: 156.0.8078.47
Activity
github-actions commentedon Nov 3, 2026
microsoft-playwright-automation commentedon Nov 3, 2026
Hi, I'm the Playwright bot and I reproduced this on Linux.
Reproduced on
1.65.0-next, commitb2f7011c5653c9acb4269eacc617dfce3c7b1545, with Chromium158.0.8127.2. Both reported problems are present: channel lookup ignores the Linux config variables, and correcting the directory alone still gives a WebSocket404because the second line ofDevToolsActivePortis ignored.The proposed fix honors
CHROME_CONFIG_HOMEbeforeXDG_CONFIG_HOMEin both directory tables and uses the WebSocket path from the file, with the existing fallback for port-only files. The existing CDP connection test now covers the report.Reproduction and checks
The test launches a persistent Chromium context in a temporary
<configHome>/google-chromedirectory with--remote-debugging-port=0. A fresh Node process then callschromium.connectOverCDP('chrome')with:XDG_CONFIG_HOME=<configHome>and an emptyCHROME_CONFIG_HOME.CHROME_CONFIG_HOME=<configHome>andXDG_CONFIG_HOMEpointing elsewhere, to check precedence.On unchanged production code, the first connection fails looking under
~/.config. With only the directory correction, it fails at/devtools/browserwith404. With the full fix, both connections report one browser context.On Ubuntu 24.04.5:
CD-001: passes headless and headed.connect-over-cdpand neighboringconnect-to-workersuites: 38 passed, 1 existing skipped test.playwright-cli list --all --json: finds the temporary Chrome profile and its endpoint with each environment configuration.npm run buildandnpm run flint: passed.This is a Chromium-only API; Firefox and WebKit do not support this connection method. Other operating systems and the reported
1.64.1release were not run because the failure reproduced on current source.Draft PR: #43884
Triaged on Linux by the Playwright bot - agent run
rickardof commentedon Nov 3, 2026
I opened #43885 with the fix and a test. I said I would wait for the assignment, but I'm opening it now because the draft #43884 appeared for this issue. I'd like to carry it through and will address review comments.
rickardof commentedon Nov 3, 2026
Thanks for looking at this. I saw #43885 was closed, and I'm fine with #43884 landing. I'd like to keep contributing to Playwright: what's the best way for an outside contributor to get a bug fix accepted, given that triage now proposes fixes automatically? Should I wait for an assignment, or is there a kind of issue you'd prefer contributors to pick up?
chore: mark v0.0.85 (#1846)
chore: mark v0.1.24 (#529)
chore(deps): update dependency @playwright/mcp to v0.0.85 (#3253)
Update agent CLIs