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
{{ message }}
Repository navigation
Access webserver hosted on WSL2 from other devices in same network. #9212
When I host the webserver from windows with ipv4 as its hostname I was able to access the website
from my mobile devices under the same network. But doing this under wsl2 ubuntu doesn't work.
When I try to run django webserver with the ip assigned to wsl2 instance, I cannot access the webserver
even from same windows device. The webserver is accessible only when it runs on 127.0.0.1 . How can I
access my wsl2 webserver from other devices under same network.
I would be very happy if you could provide me with a solution or even better release this feature on next update.
A large range of solutions are discussed in this issue #4150.
The 2 main approaches are using a TCP proxy on the windows side (docs here), or by setting up a bridge mode adapter (this method is undocumented and experimental).
This is the best option so far from my point of view in comparison to all solutions provided in the different issues around this topic. A) Because the chance is high that your development environment already has Node(.js) installed, even many IDEs require it for some code and spell checks, etc. And B) It is REALLY doing all by itself. Even installing missing dependencies when running the command first time. I just run the command npx expose-wsl. That's it. The firewall asked me after Apache2 restart to accept the request and: Violá. It took me 5 seconds with WSL2 and Win 11 / Debian to be able to access it from another device... After searching and bugging around for days. This option should be more exposed to researchers, maybe in the Windows/WSL issue queues or on top of WSL README's etc.
Follow and star the linked project and give your angel on the left shoulder a wave: there is a sponsor link on the project and I would strongly encourage you to click on it. It is really a gift that this is available. It's almost Christmas time ;)
Activity
jack775544 commentedon Nov 28, 2022
A large range of solutions are discussed in this issue #4150.
The 2 main approaches are using a TCP proxy on the windows side (docs here), or by setting up a bridge mode adapter (this method is undocumented and experimental).
icflorescu commentedon Dec 13, 2022
If you're looking for a quick way (and are familiar with Node.js/npm), simply run
npx expose-wslbefore starting your server.More details here: https://github.com/icflorescu/expose-wsl
diqidoq commentedon Oct 6, 2024
This is the best option so far from my point of view in comparison to all solutions provided in the different issues around this topic. A) Because the chance is high that your development environment already has Node(.js) installed, even many IDEs require it for some code and spell checks, etc. And B) It is REALLY doing all by itself. Even installing missing dependencies when running the command first time. I just run the command
npx expose-wsl. That's it. The firewall asked me after Apache2 restart to accept the request and: Violá. It took me 5 seconds with WSL2 and Win 11 / Debian to be able to access it from another device... After searching and bugging around for days. This option should be more exposed to researchers, maybe in the Windows/WSL issue queues or on top of WSL README's etc.Follow and star the linked project and give your angel on the left shoulder a wave: there is a sponsor link on the project and I would strongly encourage you to click on it. It is really a gift that this is available. It's almost Christmas time ;)