Skip to content

Instantly share code, notes, and snippets.

@bhubr
Created May 27, 2022 21:18
Show Gist options
  • Save bhubr/1e7b99964ac4511b79937c9a9975e890 to your computer and use it in GitHub Desktop.
Save bhubr/1e7b99964ac4511b79937c9a9975e890 to your computer and use it in GitHub Desktop.
Access server inside WSL2 from local network

Access server inside WSL2 from local network

Source: https://docs.microsoft.com/en-us/windows/wsl/networking

If you have a server listening on port 5050, running inside WSL2.

Run ip addr | grep eth0. You'll get a line similar to this:

  inet 172.29.25.111 **************

Then from PowerShell, run:

netsh interface portproxy add v4tov4 listenport=5050 listenaddress=0.0.0.0 connectport=5050 connectaddress=172.29.25.111

Assuming your Windows host's local IP address is 192.168.1.x, you'll be able to access the server via http://192.168.1.x:5050.

*You might have to open a port on the firewall (Windows Defender) too. https://pureinfotech.com/open-port-firewall-windows-10/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment