22

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

asked Nov 10, 2016 at 22:33
4
  • Should probably just be the IP address the other machine can connect by. Adding a port would be redundant. Commented Nov 10, 2016 at 22:38
  • In example 4 you can see I tried that Commented Nov 10, 2016 at 23:34
  • Example 4 actually shows you tried specifying the address of the remote machine. Not the local one... I believe Alex meant this: --remote-debugging-port=9222 --remote-debugging-address=192.168.1.2 and I want to suggest this as a possibility too: --remote-debugging-port=9222 --remote-debugging-address=0.0.0.0 Commented Feb 28, 2017 at 8:09
  • Nothing works also here (chromium in debug mode is in raspberry / linux), remote browser on a mac, through a VPN Commented Jan 13, 2021 at 10:03

5 Answers 5

30

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

answered May 26, 2017 at 11:27
Sign up to request clarification or add additional context in comments.

3 Comments

Note to others... If you want to run in windowed mode (headed mode?), an SSH tunnel gets the job done. Specify the port with --remote-debugging-port and use ssh to forward a local port to the host. Example: --remote-debugging-port=9222 on the remote machine and ssh -L 9222:localhost:9222 user@host on the local machine. Then you would connect to localhost:9222 on local to access remote's Dev Tools.
@musicin3d I am getting curl "Empty reply from server" when using ssh tunner however its working properly on host machine.
instead of using "localhost" you can explicitly use "127.0.0.1" to force ipv4 instead of ipv6 connection for the ssh forward
5

--remote-debugging-address is semantically different from chromedriver's --whitelisted-ips

The remote debugging address must specify the address to bind to. So what you want in there is your machine's IP address not the address you will be connecting from. Try binding to all interfaces with --remote-debugging-address=0.0.0.0

answered Feb 28, 2021 at 5:26

Comments

3

Try create a HTTP-proxy in your target machine.

httpProxy
 .createServer({
 target: wsurl,
 ws: true,
 localAddress: host
 })
 .listen(port);

works for me.

Abdelsalam Shahlol
1,7891 gold badge25 silver badges33 bronze badges
answered May 18, 2020 at 10:31

3 Comments

Works for me too, though the answer could be a bit more clear. Perhaps this link can help some: github.com/http-party/node-http-proxy
reverse proxy, you meant.
This answer should be modified to point out it is a method to create a reverse proxy using Nodejs. Thanks to @barney765 for the hint
3

Chrome has removed the "--remote-debugging-address" flag, it appears.

https://issues.chromium.org/issues/40242234

answered Mar 4 at 1:27

Comments

2

One way to get it to work with docker, is to use socat.

  • setup chrome, so it will start debugging on port 9222, for example

    chrome_options.add_argument("--remote-debugging-port=9222")
    
  • install socat in the docker container (before hand, or later if you want, yum install socat)

  • then run start docker with

docker run -p 9222:9223 -it <my_image> chrome...
#This binds port 9223 of the container to port 9222 on 127.0.0.1 of the host
  • then in a second window, enter the same docker container, just started
docker exec -it <container_just_started> bash
# or if there is only 1 running container
docker exec -it $(docker ps --format "{{.Names}}") bash
  • you can verify chrome is exposing 9222 inside the container by running, the following:

    curl http://127.0.0.1:9222/json
    
  • in this container, run the following socat command, (listen to traffic on 9223 and send it to 9222 inside the container)

    socat TCP-LISTEN:9223,fork TCP:127.0.0.1:9222 
    
  • running, the following on the docker host should now work

    curl http://128.0.0.1:9222/json 
    
  • You can now inspect inside of chrome using by going to

chrome://inspect/#devices
answered May 19 at 10:18

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.