跪拜 Guibai
← All articles
Frontend

Chrome 136 Blocks CDP on Default Profiles; Automation Must Bring Its Own User-Data-Dir

By 小小小小宇 ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

Any script, CI job, or scraping stack that launches ordinary Chrome with `--remote-debugging-port` and the default profile now silently fails to open a CDP socket, and the workaround discards session state or forces a move to Chrome for Testing. Teams should audit launch commands before Chrome 136 updates reach their fleet.

Summary

Chrome 136 started ignoring `--remote-debugging-port` and `--remote-debugging-pipe` when Chrome runs on the system's default user data directory. The change is anti-abuse: Google wants to stop malicious programs from reaching Cookies and login states through CDP. Automation code that launched Chrome with only the debugging flag now fails with Connection refused, ECONNREFUSED, or "Timed out waiting for websocket endpoint" while the Chrome window still opens.

Fixing it requires passing a non-default `--user-data-dir` alongside the debugging flag, which creates a fresh profile and a listening 9222 port. That trade-off costs login state, Cookies, Local Storage, extensions, and history, so "CDP connects" and "reuse the current Chrome session" are separate problems. An existing Chrome process can also swallow the new command and forward flags to the old instance, leaving the port closed even when the arguments show up in `ps`.

Protocol behavior is unchanged: WebSocket communication, Runtime, Page, Network, DOM, Debugger, Browser, and `/json/version` and `/json/list` all work as before. Playwright's `launchPersistentContext` and manual CDP connections hit the restriction hardest, while ChromeDriver and Playwright's managed temporary directories mostly escape it. Chrome for Testing, with its isolated profile and version-matched ChromeDriver, is the recommended path; Chrome 144 adds a user-authorization mode via `chrome://inspect/#remote-debugging`, where a connection pops an allow prompt instead of relying on flags.

Takeaways
— Chrome 136 ignores `--remote-debugging-port` and `--remote-debugging-pipe` when the default user data directory is in use.
— Adding `--user-data-dir=/tmp/chrome-cdp-profile` alongside the port flag restores CDP on 9222.
— Separate profiles discard login state, Cookies, Local Storage, extensions, history, and existing configuration.
— An already-running Chrome can absorb the new command-line arguments and reuse the old process, so the port never opens even when `ps` shows the flags.
— CDP itself is not deprecated: WebSocket messaging, Runtime/Page/Network/DOM/Debugger/Browser domains, and `/json/version`, `/json/list` endpoints remain compatible.
— ChromeDriver and Selenium mostly escape the restriction because modern ChromeDriver manages temporary profiles, but manual persistent profiles still hit it.
— Playwright's `chromium.launch()` is largely unaffected; `launchPersistentContext(defaultUserDataDir)` and external Chrome with `--remote-debugging-port` are affected.
— Chrome for Testing uses separate user directories and version-matched ChromeDriver, making it the recommended choice for CI and automation.
— Chrome 144 adds a browser-UI remote-debugging toggle at `chrome://inspect/#remote-debugging` that shows a user authorization prompt before allowing debugging connections.
— Troubleshooting order: curl the version endpoint, check Chrome version, verify the profile directory, check for existing Chrome processes, check port occupancy, then match client and Chrome versions.
Conclusions

Google's security rationale targets malware that reads Cookies and login state through CDP, yet the same restriction blocks legitimate scraper and automation scripts that never touch sensitive data; the burden lands on anyone who launches ordinary Chrome with the debugging flag.

The existing-process reuse failure predates 136, but the new default-profile restriction makes the silent no-port situation far more common, so teams will misdiagnose it as firewall or port conflicts.

Chrome 144's interactively authorized debugging shows the browser's direction: remote debugging becomes an explicit, human-approved action rather than a command-line flag, which pushes automation further toward Chrome for Testing and dedicated profiles.

Concepts & terms
CDP (Chrome DevTools Protocol)
The WebSocket-based protocol Chrome exposes for inspecting and controlling pages, including domains such as Runtime, Page, Network, DOM, and Debugger. Automation tools like Puppeteer and Playwright speak it through `webSocketDebuggerUrl` endpoints.
--remote-debugging-port
A Chrome command-line flag that opens a TCP port (commonly 9222) exposing CDP endpoints such as `/json/version` and `/json/list`. Chrome 136 ignores this flag when the default user data directory is in use.
--user-data-dir
The Chrome flag that selects the profile directory. A non-default value is now required to enable remote debugging, and it isolates login state, Cookies, extensions, and history from the user's normal profile.
Chrome for Testing
A Chrome distribution built for automation and testing. It uses separate user directories, matches versions with ChromeDriver, and avoids the login data and profile-reuse issues that trip up automated CDP connections.
launchPersistentContext
A Playwright API that launches the browser with a persistent user data directory, making it vulnerable to Chrome 136's restriction when pointed at the default profile.
From the discussion
Featured comments
组合搭配函数

This cut from 136 is pretty harsh — /json/list opens fine but WebSocket can't connect; without a heads-up this pitfall can waste half a day. Sticking with Chrome for Testing is a solid suggestion; regular Chrome has always been awkward for automation.

神小渣

Mainly, if you're testing a webview embedded in an app, Chrome for Testing isn't a good fit.

See top comments, translated →
Source: juejin.cn ↗ Google Translate ↗ Backup ↗