Access WSL localhost from LAN — For mobile testing

There is a scenario where you need to test on iPhone and debug on local.

Oops … we all hate the safari bug !

First is firewall

Click left panel ‘Advanced Setting’

It will open fire wall screen

Right click new rule on inbound rule specific port that localhost run. Mine is TCP 3000.

If you don’t know if it is TCP or not it is TCP. Next until end.

Second is forward to WSL

This step depends on machine. Mine have problem.

Open cmd in admin mode

This will bridge your Windows machine IP over LAN (192…) to WSL IP (172…) so that iPhone can access WSL localhost.

Thanks to this Stack Overflow Answer.

Finally see the IP

Type 192.168.1.22:3000 on your iPhone.

Here we go now we can access it over LAN.

Hope this helps !