How to access to the web server which running on WSL(Windows Subsystem for Linux) from local network

Roman picture Roman · Apr 14, 2018 · Viewed 24k times · Source

After installing Ubuntu as WSL(Windows Subsystem for Linux) I've run:

root@teclast:~# python3 -m http.server
Serving HTTP on 0.0.0.0 port 8000 ...

and try to access to this web server from my windows machine http://0.0.0.0:8000 or http://192.168.1.178:8000 but no success, web server available only by the address http://127.0.0.1:8000 or http://localhost:8000 it means that I can't connect to this web server from another pc in my network. Is it possible to getting an access to WSL from outside?

Answer

Toran Sahu picture Toran Sahu · Aug 24, 2018

Please follow the steps mentioned in the link shared by @erazerbrecht and run your HTTP server by providing your ip address (instead of using localhost) and port number.

example:
root@teclast:~# python3 -m http.server -b 192.168.1.178 8000 Serving HTTP on 192.168.1.178 port 8000 (http://192.168.1.178 :8000/) ...

Otherwise you can also do this instead of following the link:
1. Goto Windows defender firewall
2. select inbound
3. create new rule; next
4. select Program as a rule type; next
5. select All Program; next
6. select allow the connection; next
7. check all 3 (Domain, Private, Public); next
8. provide rule a name
9. finish
10. Your are good to go