You can use port forwarding to:
- Case 1. Debug a tab opened on a different Chrome instance.
- Case 2. Host a site on a development machine web server, then access the content from an Android device through a USB cable.
In Case 2, port forwarding works through a listening TCP port on your Android device that maps to a TCP port on your development machine. Traffic between the ports travel through the USB connection between your Android device and development machine, so the connection doesn't depend on your network configuration.
Additionally, if your web server is using a custom domain, you can set up your Android device to access the content at that domain with custom domain mapping.
Set up port forwarding
Depending on your case, follow the next steps.
Case 1: Set up port forwarding to another Chrome instance
Run another Chrome instance with the
--remote-debugging-port=PORT
parameter, for example:MacOS
open -a "Google Chrome" --args --remote-debugging-port=PORT
Windows
start chrome --remote-debugging-port=PORT
Linux
google-chrome --remote-debugging-port=PORT
In the Chrome instance you are debugging with:
- Open
chrome://inspect/#devices
. - Make sure
Discover network targets is checked.
- Click Configure next to the checkbox.
In Target discovery settings, enter
localhost:PORT
, checkEnable port forwarding, and click Done.
- Open