You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently on WSL 2 it's necessary to add a port proxy with PowerShell in order to access servers running on it in your LAN. This relevant section on the docs has the following snippet
Suppose I'm running a Vite server and want to have access to it on my LAN. If I substitute the ports in this snippet with 5173 and run it, checking afterward said rule with netsh interface portproxy show v4tov4 will show it was created successfully, with the connectaddress variable being resolved to my WSL 2 network adapter IP.
But it won't work. If I first run wsl hostname -I and then substitute this IP into the snippet too, the traffic will be forwarded as expected.
What I personally think is confusing is that executing the snippet substituting only the ports won't fail. Even checking said rule afterwards will show the WSL machine IP as if the command was successful, even if it won't actually work. This may lead users to think this step was done correctly and the reason they can't connect to their server by their LAN was because of something else, incorrect firewall rules for example.
Maybe if the connect value was between <> as well as the ports and wsl hostname -I was introduced before, it would make it clearer to the user that they are supposed to first to get the machine IP and then substitute it into the snippet, as they did with the ports.
The text was updated successfully, but these errors were encountered:
THANK YOU! I no joke spent about four hours on this. I could not for the life of me figure out why none of the traffic on my port was being forwarded to WSL2 (I checked in Wireshark) and googled a million irrelevant things before I found this. The worst thing is that the rule looks identical when I do "netsh interface portproxy show all" the only difference is IT WORKS.
I thought that syntax was weird at first, but I ignored it. It turns out that the syntax for command substitution in Powershell is also $(). It's very strange that the command would accept (wsl hostname -I) as a valid argument.
Documentation Issue
Currently on WSL 2 it's necessary to add a port proxy with PowerShell in order to access servers running on it in your LAN. This relevant section on the docs has the following snippet
Suppose I'm running a Vite server and want to have access to it on my LAN. If I substitute the ports in this snippet with 5173 and run it, checking afterward said rule with
netsh interface portproxy show v4tov4
will show it was created successfully, with the connectaddress variable being resolved to my WSL 2 network adapter IP.But it won't work. If I first run
wsl hostname -I
and then substitute this IP into the snippet too, the traffic will be forwarded as expected.Link to documentation page
https://learn.microsoft.com/en-us/windows/wsl/networking#accessing-a-wsl-2-distribution-from-your-local-area-network-lan
Suggested Improvements
What I personally think is confusing is that executing the snippet substituting only the ports won't fail. Even checking said rule afterwards will show the WSL machine IP as if the command was successful, even if it won't actually work. This may lead users to think this step was done correctly and the reason they can't connect to their server by their LAN was because of something else, incorrect firewall rules for example.
Maybe if the connect value was between <> as well as the ports and
wsl hostname -I
was introduced before, it would make it clearer to the user that they are supposed to first to get the machine IP and then substitute it into the snippet, as they did with the ports.The text was updated successfully, but these errors were encountered: