'In Linux how do you set it that Google Chrome runs in debugging mode by default

I specifically need this for puppeteer to open a window in my current browser so that my user data can be accessed and I can login to places automatically

In Windows, you enable the setting by adding this to the shortcut icon's 'target' field, '–remote-debugging-port=9222' This will automatically run Chrome with that setting so you have all your login sessions available

How can I have the same effect in Linux where I enable the setting permanently? There is a way to run Chrome in this way by running /usr/bin/google-chrome-stable --remote-debugging-port=9220 in your terminal, but where can I edit a file to have this permanently enabled?

I've also run into a small error right now trying to start my puppeteer script.

FetchError: Failed to fetch browser webSocket URL from http://localhost:9222/json/version: request to http://localhost:9222/json/version failed, reason: connect ECONNREFUSED 127.0.0.1:9222
    at ClientRequest.<anonymous> (/home/me/Coding/whatsapp-bot-puppeteer/node_modules/node-fetch/lib/index.js:1461:11)
    at ClientRequest.emit (node:events:526:28)
    at Socket.socketErrorListener (node:_http_client:442:9)
    at Socket.emit (node:events:526:28)
    at emitErrorNT (node:internal/streams/destroy:157:8)
    at emitErrorCloseNT (node:internal/streams/destroy:122:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  type: 'system',
  errno: 'ECONNREFUSED',
  code: 'ECONNREFUSED'
}

I'm Linux noob, so I need some help please ^-^



Solution 1:[1]

I have found a slight workaround, but it does require you to create a chrome instance through the terminal and then use a websocket connection string You will also have to log into your new chrome window and sign in wherever

/usr/bin/google-chrome-stable --remote-debugging-port=9222 --no-first-run --no-default-browser-check --user-data-dir=remote-profile

Running this in a Linux terminal will provide you with a ws connection you copy and then paste into your puppeteer script

Please look here for an example: https://blog.nutjane.me/how-to-run-puppeteer-with-existing-chrome-profile-f42954bfc70c

You just have to make sure not to close this browser instance if you're planning on having a puppeteer script run the whole time. Otherwise you'll have to restart the chrome browser from the terminal and update the ws connection string in your puppeteer file :)

I've tested a quick script with puppeteer now, and I am having success with it :D

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ruben Verster