When launching server processes on WSL2 you will need to find the ip address of the WSL2 instance to be able to browse the app/process on Windows.
For example, if I wanted to start a simple python server on port 9000 like this: python3 -m http.server 9000
,
I would need to find the ip using the following command in the terminal:
ip addr | grep eth0
. Now with this ip address, I can access the site in windows.
As an example, if the ip that gets returned is 89.56.213.91
,
I can access that app by going to a browser on Windows and typing in 89.56.213.91:9000
.
This happens because WSL2 is running like a VM with its own separate ip address. You can replace the python simple http server with
any process that uses networking, e.g. jupyter notebook
.