Notes on chrome remote debugging

Thu 07 August 2014 by Fred Clift

These are mostly notes for me, but you might find them useful also.

On my laptop, I run chrome and usually have many, many tabs open across a few windows. Google searching for me usually ends up with me open-in-new-tabbing the first 5 or 10 links concurrently... It bugs me when I have to close my browser and loose my set of open tabs, though, in the case of crashes, modern browsers do a decent job of remembering what I had up.

Chrome at least does not remember my open tabs if I quit chrome cleanly. Now and then, I need to use Chrome's Developer Tools. Sometimes I need to run the developer tools remotely. Chrome Developer Tools are pretty sweet - lots of debugging and performance tools for web development. Generally you run the developer tools in the same instance of chrome as whatever you're debugging, but you can actually run the UI on another instance of Chrome, either on the same machine or remotely.

Running them remotely is almost indistinguishable from running them within the same browser instance - cool technology the Chrome guys have written.

All you need to do is to use the command line option

--remote-debugging-port=9222

or whatever port you want and chrome will start up listening on that port for connections from a remote debugger. To debug, just point your OTHER chrome browser, on the same or other box at

http://<YOUR IP>:9222/

and you'll get a list of the open tabs/frames. Click on one and off you go.

So, my problem. I have chrome open with 60 or 70 tabs, across 3 or 4 windows. I want to run chrome with that command line option so I can play around with some command-line tools to to remote debugging/control. I don't want to shut down chrome...

So, I use another command line option

--user-data-dir=/tmp/foo

and I can invoke a second instance of chrome, that is completely separate from what I already have running.

On my macbook:

/Applications/Google Chrome.app/Contents/MacOS/Google\ Chrome --user-data-dir=/tmp/foo --remote-debugging-port=9222

Presto - a new chrome instance, using a separate profile, with remote debugging enabled, without having to shut down my precious tabs.