microsoft/playwright · error · Error
Could not connect to ${channel}: DevToolsActivePort file not
Error message
Could not connect to ${channel}: DevToolsActivePort file not found at ${devToolsActivePortPath}.\n${remoteDebuggingHint(channel)} What it means
Thrown by resolveChannelEndpoint after it computed devToolsActivePortPath for the channel and fs.readFile resolved to undefined (the .catch returns undefined). The DevToolsActivePort file is written by Chrome when it starts with remote debugging; its absence means Chrome is not running with debugging or is using a different user-data-dir.
Source
Thrown at packages/playwright-core/src/server/chromium/chromium.ts:487
url: httpURL,
headers,
}, async (_, resp) => new Error(`Unexpected status ${resp.statusCode} when connecting to ${httpURL}.\n` +
`This does not look like a DevTools server, try connecting via ws://.`)
);
return JSON.parse(json).webSocketDebuggerUrl;
}
async function resolveChannelEndpoint(progress: Progress, channel: string): Promise<string> {
const userDataDir = defaultUserDataDirForChannel(channel);
if (!userDataDir)
throw new Error(`Connecting to ${channel} by channel name is not supported on ${process.platform}.`);
const devToolsActivePortPath = path.join(userDataDir, 'DevToolsActivePort');
progress.log(`<ws preparing> reading ${devToolsActivePortPath}`);
const contents = await progress.race(fs.promises.readFile(devToolsActivePortPath, 'utf-8').catch(() => undefined));
if (!contents) {
throw new Error(
`Could not connect to ${channel}: DevToolsActivePort file not found at ${devToolsActivePortPath}.\n` +
remoteDebuggingHint(channel));
}
const port = parseInt(contents.trim(), 10);
if (isNaN(port))
throw new Error(`Could not connect to ${channel}: invalid DevToolsActivePort file at ${devToolsActivePortPath}.`);
const endpoint = `ws://localhost:${port}/devtools/browser`;
progress.log(`<ws preparing> resolved channel "${channel}" to ${endpoint}`);
return endpoint;
}
async function seleniumErrorHandler(params: HTTPRequestParams, response: http.IncomingMessage) {
const body = await streamToString(response);
let message = body;
try {
const json = JSON.parse(body);View on GitHub (pinned to c8fc3bf8d3)
Solutions
- Quit all Chrome instances and relaunch with --remote-debugging-port=9222, then connect by http URL instead of channel name.
- Enable remote debugging in Chrome: chrome://inspect -> 'Allow remote debugging for this browser instance' (per the embedded hint).
- Make sure no other Chrome process owns the channel's default user-data-dir; close background Chrome.
Example fix
// before
const b = await chromium.connectOverCDP('chrome');
// after
// shell: google-chrome --remote-debugging-port=9222
const b = await chromium.connectOverCDP('http://localhost:9222'); Defensive patterns
Strategy: validation
Validate before calling
import fs from 'fs';
import os from 'os';
import path from 'path';
async function cdpReady(profileDir: string): Promise<boolean> {
try { return !!(await fs.promises.readFile(path.join(profileDir, 'DevToolsActivePort'), 'utf-8')); }
catch { return false; }
} Type guard
function isChromeRunningWithDebugging(profileDir: string): Promise<boolean> {
return fs.promises.access(path.join(profileDir, 'DevToolsActivePort')).then(() => true).catch(() => false);
} Try / catch
try {
browser = await chromium.connectOverCDP('chrome');
} catch (e) {
if (/DevToolsActivePort file not found/.test(String(e.message))) {
throw new Error('Start Chrome with --remote-debugging-port, then retry');
}
throw e;
} Prevention
- Always launch Chrome with --remote-debugging-port before connectOverCDP by channel.
- Ensure no other Chrome process holds the channel's default user-data-dir.
When it happens
Trigger: chromium.connectOverCDP('chrome') where Chrome is not running, or is running without --remote-debugging-port, or is using a profile directory other than the one Playwright expects for that channel.
Common situations: Chrome was started normally by the desktop session. Another Chrome instance already holds the user-data-dir. Profile path differs because of a custom channel build. Stale lock files preventing the file from being written.
Related errors
- Could not connect to ${channel}.\n${remoteDebuggingHint(chan
- Could not connect to ${channel}: invalid DevToolsActivePort
- Connecting to ${channel} by channel name is not supported on
- Connecting over CDP is only supported in Chromium and WebKit
- Passing a ConnectionTransport to connectOverCDP is not suppo
AI-assisted analysis of microsoft/playwright@c8fc3bf8d3 (2026-08-12).
Data as JSON: /api/errors/c1ed1723d0027362.
Report an issue: GitHub.