Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome remote debugging from another machine

Chrome has a really awesome feature that allows you to open the dev tools from another browser or window. It works by starting chrome with this flag:

--remote-debugging-port=9222

Then from another window/browser you can go to http://localhost:9222 and open dev tools for any running tab in Chrome. For security reasons Chrome will not allow access from another machine by IP, lets say http://192.168.1.2:9222.

However there is an additional flag that indicates it opens this ability, here is what Chrome has to say for it:

--remote-debugging-address 

Use the given address instead of the default loopback for accepting remote debugging connections. Should be used together with --remote-debugging-port. Note that the remote debugging protocol does not perform any authentication, so exposing it too widely can be a security risk.

Either it's not working or I have no idea how to format it. I have tried the following:

--remote-debugging-port=9222 --remote-debugging-address=http://192.168.1.2:9222
--remote-debugging-port=9222 --remote-debugging-address=http://192.168.1.2
--remote-debugging-port=9222 --remote-debugging-address=192.168.1.2:9222
--remote-debugging-port=9222 --remote-debugging-address=192.168.1.3 //maybe thinking its supposed to be the IP of the remote machine

The target machine a Mac

like image 778
Sean256 Avatar asked Nov 10 '16 22:11

Sean256


People also ask

Is remote debugging port safe?

While it may be acceptable for development, it is not recommended for production systems. Caution - This configuration is insecure: any remote user who knows (or guesses) your port number and host name will be able to monitor and control your Java applications and platform.

How do I find debug address?

An inspector window should open, enabling you to remotely debug the Web Receiver app. The device IP address can be found by selecting the device in the Google Home app, going to settings, and looking under the Information section. Select the session you would like to debug by clicking its Remote Debugging link.

How can I stop Chrome from going into debug mode?

Go to the "Sources" tab. At the top right hand side, toggle the button that looks like the pause symbol surrounded by a hexagon (button on the far right) until the color of the circle turns black to turn it off. If the pause symbol isn't blue it may be that you've accidentally marked a line for debugging inspection.


1 Answers

it turned out, that the option "--remote-debugging-address" can only be used for the headless mode ("--headless") and is intended to be used for tests when the browser runs in a docker container and not for remote debugging.

The parameter of "remote-debugging-address" must be the numeric ip-adress of a local network interface of the machine where you start Chrome with "--remote-debugging-address". When using any non-local ip-address you will get the following errors:

[0526/132024.480654:ERROR:socket_posix.cc(137)] bind() returned an error, errno=49: Can't assign requested address
[0526/132024.480766:ERROR:devtools_http_handler.cc(226)] Cannot start http server for devtools. Stop devtools.

On my Mac I can start the Chrome Canary version from today using this command line (the current stable version just crashes with "--headless"):

/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary  --remote-debugging-port=9222 --remote-debugging-address=192.168.1.20 --headless

In another shell you can see, that this address is used to listen on the socket:

netstat -a -n | grep 9222
tcp4       0      0  192.168.1.20.9222      *.*                    LISTEN   

Without "--headless" the output will look like this:

tcp4       0      0  127.0.0.1.9222         *.*                    LISTEN

Michael

like image 160
Michael Dreher Avatar answered Sep 19 '22 01:09

Michael Dreher