跪拜 Guibai
← Back to the summary

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

How to Use the CDP Protocol After Chrome 136

After Chrome 136, the biggest change is not that the CDP protocol itself changed, but that Chrome added restrictions on "how to enable remote debugging".

1. Core changes in Chrome 136

Starting with Chrome 136, the following arguments are ignored when using the default user data directory:

--remote-debugging-port=9222
--remote-debugging-pipe

That is, the following launch method used to work:

google-chrome \
  --remote-debugging-port=9222

But on Chrome 136 and later, if it uses the system's default Chrome user directory, it may not actually start the CDP service.

Chrome's official reasoning is mainly to prevent malicious programs from reading Cookies, login states, and sensitive information in the browser through CDP.


2. The correct way to launch

You must also specify a non-default user data directory:

google-chrome \
  --remote-debugging-port=9222 \
  --user-data-dir=/tmp/chrome-cdp-profile

macOS example:

/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome \
  --remote-debugging-port=9222 \
  --user-data-dir=/tmp/chrome-cdp-profile

Then you can visit:

http://127.0.0.1:9222/json/version
http://127.0.0.1:9222/json/list

If you can see webSocketDebuggerUrl, CDP has started successfully.


3. Symptoms that may appear

Symptom 1: Port 9222 is not listening

The program started Chrome, but visiting:

http://127.0.0.1:9222/json/version

shows:

Connection refused

or:

ERR_CONNECTION_REFUSED

The reason is usually that Chrome 136 ignored --remote-debugging-port.


Symptom 2: CDP client connection timeout

For example, programs such as Puppeteer, Playwright, browser-use, and Chrome DevTools MCP may show:

ECONNREFUSED
WebSocket connection failed
Timed out waiting for websocket endpoint
BrowserType.launchPersistentContext failed

The Chrome window is already open, but the automation program keeps waiting for the CDP address.


Symptom 3: The arguments appear to be passed in, but do not actually take effect

For example, the command line does contain:

--remote-debugging-port=9222

but:

ps aux | grep Chrome

shows the argument, yet port 9222 has no service.

This is easily misdiagnosed as a firewall, port conflict, or CDP client version issue, when in fact it may be Chrome 136's security policy blocking remote debugging on the default user directory.


Symptom 4: Cannot reuse the original login state

After switching to:

--user-data-dir=/tmp/chrome-cdp-profile

Chrome uses a new user data directory, so it usually loses:

So "can connect to CDP" and "can reuse the current Chrome login state" are two separate issues.


Symptom 5: When launching Chrome directly, Chrome reuses an existing process

If a Chrome is already running on the system, running again:

chrome --remote-debugging-port=9222 ...

The new command may just forward arguments to the existing Chrome process, rather than creating a truly CDP-enabled new instance.

So even if the arguments are specified, there may be no listening port. Using a separate --user-data-dir avoids this process reuse problem.


4. What has not changed

Chrome 136 did not completely deprecate CDP. The following are usually still compatible:

The change is mainly:

Whether Chrome allows starting the remote debugging service, not that the CDP message format changed.

Therefore, if you have already successfully obtained:

ws://127.0.0.1:9222/devtools/browser/...

The way you send CDP commands afterward usually does not need to change because of Chrome 136.


5. Differences between ChromeDriver, Playwright, and manual CDP

ChromeDriver / Selenium

Modern ChromeDriver usually uses a temporary user directory or internal pipe itself, so many Selenium scenarios are not significantly affected.

But if you manually specify:

You may still encounter the Chrome 136 restriction.

Playwright

Ordinary:

chromium.launch()

Usually the browser and temporary directory are managed by Playwright, so the impact is smaller.

But scenarios like these are easily affected:

chromium.launchPersistentContext(defaultUserDataDir, ...)

Or using an external Chrome and relying on:

--remote-debugging-port=9222

Manual CDP connection

Most easily affected, because it usually directly relies on:

--remote-debugging-port=9222

You must switch to a non-default directory.


6. Chrome for Testing

Chrome officially recommends Chrome for Testing for automation scenarios.

Its differences from regular Chrome:

For stable automation tasks, the recommendation is:

Chrome for Testing + separate user-data-dir + CDP/ChromeDriver

rather than directly controlling the Chrome users use daily.


7. Further changes after Chrome 136

Later versions introduced a more user-authorization-oriented remote debugging approach. Taking Chrome 144 features as an example, you can explicitly enable remote debugging at:

chrome://inspect/#remote-debugging

Features of this mode:

This differs from the 136 --user-data-dir restriction:

Version/method Main change
Chrome 135 and earlier The default user directory usually could start CDP with a port
Chrome 136+ The default user directory no longer allows starting via --remote-debugging-port/pipe
Chrome 136+ recommended Use a non-default --user-data-dir
Chrome 144-related new method Enable through the browser UI, with user authorization for connections

Actual troubleshooting order

When CDP cannot be connected, check in this order:

curl http://127.0.0.1:9222/json/version

If it fails:

  1. Confirm whether the Chrome version is 136 or higher
  2. Confirm whether the default user directory is being used
  3. Add a separate directory:
--user-data-dir=/tmp/chrome-cdp-profile
  1. Confirm whether an existing Chrome process is occupying the current user directory
  2. Confirm whether the port is occupied by another program
  3. Then check whether the CDP client and Chrome version match

In short:

Chrome 136 did not cancel CDP, it just forbids the default user directory of regular Chrome from directly exposing CDP. The old approach of "directly adding --remote-debugging-port to Chrome" now requires a separate user data directory after 136, or switching to Chrome for Testing.

Comments

Top 1 of 2 from juejin.cn, machine-translated. The original thread is authoritative.

组合搭配函数

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.