10

Chrome can be run to support remote debugging by starting it via the command line with a prompt such as chrome.exe --remote-debugging-port=9222 --user-data-dir=C:/foo. This is often used to debug on android or iOs using a Browser on a Desktop Device but I would like to debug chrome running on a desktop PC. from a "client browser" on the same machine one can call localhost:9222 and see the server browser, calling localhost:9222/json will result in a json representation of the tabs open in the "server browser". This works just fine.

However, when I try to use another device in the same (wifi) network by calling [local IP]:9222 or [local IP]:9222/json (local IP is the IP of the server browser) I get a connection timeout. Is it possible to use remote debugging in such way? Are any other switches needed when starting the browser?

Edit I have found some use of forward tcp for the debugging of mobile devices, but there does not seem to be such a switch for chrome.

Edit 2 This seems to be a bit of a duplicate of the questions here and here however, as of yet I have not gotten the solutions presented there to work.

So, apparently this comes down to forwarding a port to localhost:9222. However, at least on windows machines I have no luck with SSH tunnels. Are there any other ways to forward on the machine?

Community
  • 1
  • 1
Lukas Ruge
  • 2,204
  • 3
  • 30
  • 42

3 Answers3

15

As you've mentioned it, the solution is to forward the port 9222. Below you find approaches for Linux and Windows.

Linux

After having started chrome with

chrome --remote-debugging-port=9222

Forward the port

ssh -L 0.0.0.0:9223:localhost:9222 localhost -N

This way you can access the debuggin interface from an external device on port 9223 using a Chrome browser.

Windows

As seen in this answer, on windows (tested on 7,8) the easiest way to do portforwarding without 3rd party apps is via netsh

I've created a batch file with the following content. It has to be ran as administrator, and with no previous chrome windows open:

netsh interface portproxy delete v4tov4 listenport=9222 listenaddress=0.0.0.0
start /b cmd /c call "\program files\google\chrome\application\chrome.exe" -remote-debugging-port=9222
timeout 5
netsh interface portproxy add v4tov4 listenport=9222 connectaddress=127.0.0.1 connectport=9222 listenaddress=0.0.0.0

This way you can access the debuggin interface from an external device on port 9222.

Make also sure that no firewall is blocking the corresponding port.

Community
  • 1
  • 1
Matyas
  • 13,473
  • 3
  • 60
  • 73
  • 1
    On Linux, after ssh command, I got ```channel 1: open failed: connect failed: Connection refused``` on console side & ```site not found``` on remote browser – Damien C Jan 13 '21 at 09:46
  • How did you start start chrome with 9222? – toddmo Jan 17 '23 at 16:24
7

You can achieve the same behaviour by adding the argument --remote-debugging-address=[YOUR_EXTERNAL_IP_ADDRESS] as reported here, without any additional software other than Chrome itself.

maaw
  • 1,276
  • 13
  • 13
  • 1
    This should be marked as the correct answer now. Worked perfectly. – gimp3695 Feb 01 '19 at 22:05
  • Its working! Another important thing to mention is that if you get blank console page, you probably should allow insecure content on site settings of chrome (click on the small lock icon on the address bar) source - https://developers.google.com/cast/docs/debugging/remote_debugger – Avishay116 Jun 07 '20 at 12:35
  • Did not work for me in chrome nor chromium (while trying to get around the google-chrome doesn't work over X since version 77) Unbunti 18.04 – fundagain Jul 19 '20 at 14:13
  • 2
    `remote-debugging-address` only works for the headless mode. Very unfortunate, because the only reason I want to use this feature is to see what tests do on my local machine. – Jelle De Loecker Mar 21 '21 at 16:23
  • Set it to --remote-debugging-address=0.0.0.0 to remote access from another computer on same local netword – Harald Hoerwick Aug 19 '22 at 19:55
2

I've successfully used RInetD for easy port-forwarding in Windows 7, tried this and it worked like a charm, externally debugging a Chrome browser in Windows from a Chrome in Mac/Ubuntu.

You can download rinetd from:

http://www.boutell.com/rinetd/

Unzip the file, create an empty file with any name (I used rinetd.conf), with this content:

0.0.0.0 9223 127.0.0.1 9222

The in Windows console run it with:

rinetd.exe -c rinetd.conf

And voila!

prigazzi
  • 21
  • 3