I used to debug Chrome with PuppeteerSharp. For that, I run Chrome with command:
"C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222 --profile-directory="Default"
Then I wait Chrome t start and make GET request to http://127.0.0.1:9222/json/version
to get webSocketDebuggerUrl value, thich I pass to
_browser = await Puppeteer.ConnectAsync(new()
{
BrowserWSEndpoint = webSocketDebuggerUrl, // value got from Chrome /json/version
});
And that works fine for a year until today. Now if I request http://127.0.0.1:9222/json/version, it gives me ERR_CONNECTION_REFUSED
What I tried is to
9222 to 9223 - no effect9222 - no effectThe Chrome version I got is 136.0.7103.49 (Official Build) (64-bit) - latest at the moment
Then I push my other PC, which got at moment Chrome 134...., started Chrome with --remote-debugging-port=9222 and it works. Then I decided to update chrome to latest and it breaks...
So my question is did something changed for chrome remote debugging in latest releases? How now should I start Chrome to debug, how should I get webSocketDebuggerUrl value? Or most likely there is some new settings had to be set to allow get that value
Some similar struggles from before
chrome://inspect/, but didn't found any webSocketDebuggerUrlHere is also different approach to gain that value, but it looks way too comlex
Have to mention it also not available from chrome://version/
I have found a workaround, but not a solution:
Back in Mar. '25, an article was posted on Chrome for Developers, stating Google would disable Chrome DevTools Protocol connections for the default data directory, starting from Chrome 136.
As of now, there are 3 alternative solutions/workarounds at our disposal as follows:
Use other Chromium-based browsers such as Edge and Opera, which I, for one, didn't find too hot personally.
Use Chrome for Testing, which is spared from the above breaking change for now. This policy, however, is at the mercy and whim of Google and may or may not change further down the road.
In the following instruction, make sure to customize your user name and %USERPROFILE%\AppData\Chrome for CDP to your needs/liking.
%LOCALAPPDATA%\Google\Chrome\User Data folder to another location with no possible permission issues, e.g., %USERPROFILE%\AppData\Chrome for CDP (or C:\Users\your user name\AppData\Local\Google\Chrome).Target command line to, e.g., %ProgramW6432%\Google\Chrome\Application\chrome.exe --user-data-dir="%USERPROFILE%\AppData\Chrome for CDP\User Data" --remote-debugging-port=9222.To ensure this custom profile be used when opening .url files:
regedit, navigate to the HKEY_CLASSES_ROOT\ChromeHTML\shell\open\command path and export the Default data to a file as a backup."C:\Program Files\Google\Chrome\Application\chrome.exe" --user-data-dir="C:\Users\your user name\AppData\Chrome for CDP\User Data" --remote-debugging-port=9222 --single-argument %1. Note that the percent notation for paths (environment variable expansion) won't work here.Naturally, you'll have to sign in to websites again. FWIW, I went with this Option 3.
Add --user-data-dir=XXX into your usual command
e.g. --user-data-dir=remote-debug-profile
Viola - Chrome in debug mode will run like usual
But your folder will have a new folder XXX & git will record 2K+ new files
e.g. ./remote-debug-profile
Update your .gitignore with XXX
e.g. remote-debug-profile in .gitignore
As @johnlee & @Mini elephant point out:
Back in Mar. '25, an article was posted on Chrome for Developers, stating Google would disable Chrome DevTools Protocol connections for the default data directory, starting from Chrome 136.
Further reading down the blog:
For developers who need to debug Chrome (for example, from VSCode), the instructions already specify use of a custom user data dir and we continue to recommend this approach to isolate any debugging from any real profiles.
Pointing to this Browser Debugging documentation:
edge.exe --remote-debugging-port=9222 --user-data-dir=remote-debug-profileSetting the
--remote-debugging-porttells the browser to listen on that port for a debug connection. Setting a separate--user-data-dirforces a new instance of the browser to be opened; if this flag isn't given, then the command will open a new window of any running browser and not enter debug mode.
Attackers has been increasingly using Chrome Remote Debugging to perform attacks & extract cookies
Because of this security issues, Chrome Remote Debugging will change the following from Chrome 136
1 - Chrome Remote Debugging cannot remotely debug any real user profile & default Chrome data directory
Flag --remote-debugging-port & --remote-debugging-pipe will be ignored silently & Chrome will not enter debug mode if
--user-data-dir is providedRegardless of the profile choice:
Any existing user profile flag is given, e.g. --profile-directory=Profile\ 5
No profile is specified, that user can select which user profile to launch with
2 - Chrome Remote Debugging can only remotely debug non-standard, custom user profile & data directory
Chrome will only enter debug mode if --user-data-dir is provided
# MacOS zsh
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome \
--remote-debugging-port=9222 \
--profile-directory=Profile\ 5 \
--user-data-dir=remote-debug-profile
Open chrome://version/ in the new Chrome Remote Debugging browser, you'll notice:
Executable Path /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
Profile Path /Users/MY_ACCOUNT/YOUR_PWD/remote-debug-profile/Profile 5
... which are completely separated from the default Chrome data directory with existing real user data:
Executable Path /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
Profile Path /Users/MY_ACCOUNT/Library/Application Support/Google/Chrome/Profile 5
Tested in MacOS, we have the following findings:
--profile-directory
Flag --profile-directory=Profile\ 5 is not pointing to the existing Chrome user profile 5, but to the new non-standard data directory
--remote-debugging-port & --user-data-dir
Chrome will only enter debug mode if both of the flags are present
--remote-debugging-port=9222 launch Chrome remote debugging in port 9222
--user-data-dir=remote-debug-profile will create a brand new non-standard Chrome user profile & data directory in your working directory
From here, your can perform your usual gmail/Google login, account login for persistent cookies, debugging, scraping, etc...
Just remember to always launch it in the same directory
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With