If you just started to use WSL, you may encounter the issue that You only can access your service hosted in the WSL from the host by localhost, but not the IP address. For example, you have a web service that listens to port 8080. In your web browser, you can browse the site with http://localhost:8080, but http://127.0.0.1:8080.
The reason is that you need to use the WSL IP address. An easy way to find the address is to execute the below command in WSL terminal.
ip addr | grep eth0 | cut -d ' ' -f 6 | tail -1 | cut -d '/' -f 1
The output is the WSL IP address. For example, 172.22.110.133. So you can browse the site with http://172.22.110.133:8080
Enjoyed this article? Support my work with a coffee ☕ on Ko-fi.