@@ -86,7 +86,7 @@ nlm login --wsl
8686```
8787
8888This will:
89- - Detect your Windows IP address from WSL
89+ - Detect the WSL networking mode and Windows host address
9090- ** Check Windows Firewall setup** (prompts with instructions)
9191- Launch Chrome on Windows on port 9223 with remote debugging
9292- Connect via the port proxy on port 9222
@@ -109,14 +109,15 @@ When you run `nlm login --wsl`:
109109
110110```
111111WSL Terminal
112- ↓ detects Windows host IP (from default gateway)
112+ ↓ detects networking mode with wslinfo
113+ ↓ uses the default gateway (NAT) or 127.0.0.1 (mirrored)
113114 ↓ launches /mnt/c/Program Files/Google/Chrome/Application/chrome.exe
114115Windows Chrome
115116 ↓ starts on 127.0.0.1:9223 (Windows side, localhost only)
116117netsh portproxy
117118 ↓ forwards 0.0.0.0:9222 → 127.0.0.1:9223
118119WSL Auth Script
119- ↓ connects to http://172.x.x.x: 9222 (via port proxy)
120+ ↓ connects to the Windows host on port 9222 (via port proxy)
120121 ↓ opens notebook.google.com tab
121122 ↓ waits for login
122123 ↓ extracts cookies via CDP
@@ -180,13 +181,18 @@ cat /etc/resolv.conf
180181grep nameserver /etc/resolv.conf
181182```
182183
183- You should see an IP like ` 172.20.x.x ` . If not, your WSL2 networking may be in a different mode.
184+ In NAT mode, you should see an IP like ` 172.20.x.x ` . In mirrored mode, the Windows host is
185+ available at ` 127.0.0.1 ` .
184186
185187** Workaround:**
186188``` bash
187- # Find Windows IP manually
188- WINDOWS_IP=$( ip route show | grep default | awk ' {print $3}' )
189- nlm login --cdp-url http://$WINDOWS_IP :9222
189+ # Find the Windows host address manually
190+ if [ " $( wslinfo --networking-mode 2> /dev/null) " = " mirrored" ]; then
191+ WINDOWS_IP=127.0.0.1
192+ else
193+ WINDOWS_IP=$( ip route show default | awk ' {print $3; exit}' )
194+ fi
195+ nlm login --cdp-url " http://${WINDOWS_IP} :9222"
190196```
191197
192198### "Chrome did not start within 30 seconds"
@@ -202,7 +208,12 @@ Sometimes Windows firewall or antivirus blocks the connection.
202208 ```
203209 ``` bash
204210 # In WSL (wait a few seconds first)
205- nlm login --cdp-url http://$( grep nameserver /etc/resolv.conf | awk ' {print $2}' ) :9222
211+ if [ " $( wslinfo --networking-mode 2> /dev/null) " = " mirrored" ]; then
212+ WINDOWS_IP=127.0.0.1
213+ else
214+ WINDOWS_IP=$( ip route show default | awk ' {print $3; exit}' )
215+ fi
216+ nlm login --cdp-url " http://${WINDOWS_IP} :9222"
206217 ```
207218
208219### Terminal still goes black
@@ -245,11 +256,15 @@ CHROME_PID=$!
245256# Wait for startup
246257sleep 3
247258
248- # Get Windows IP
249- WINDOWS_IP=$( grep nameserver /etc/resolv.conf | awk ' {print $2}' )
259+ # Get the Windows host address
260+ if [ " $( wslinfo --networking-mode 2> /dev/null) " = " mirrored" ]; then
261+ WINDOWS_IP=127.0.0.1
262+ else
263+ WINDOWS_IP=$( ip route show default | awk ' {print $3; exit}' )
264+ fi
250265
251266# Login via CDP
252- nlm login --cdp-url http://$WINDOWS_IP :9222
267+ nlm login --cdp-url " http://${ WINDOWS_IP} :9222"
253268
254269# Cleanup
255270kill $CHROME_PID
0 commit comments