When I run "ng serve" from WSL2 (Ubuntu 20.04), I am able to access the angular application from Windows 10 Host by browsing to http://localhost:4200.
Can someone explain how this is possible? I understand that WSL2 is working as a virtual machine with its own ip address. How can Windows 10 host access the angular app on WSL2 using "http://localhost:4200" ?
On a different note, when I run tomcat from WSL2, I am NOT able to access the tomcat application from Windows using "http://localhost:8080".
Thanks in advance Paul
The assumption that WSL2 is working as a virtual machine with its own ip address depends on the Windows 10 version.
Also read this article. It explains why and how.
If you are building a networking app (for example an app running on a NodeJS or SQL server) in your Linux distribution, you can access it from a Windows app (like your Edge or Chrome internet browser) using localhost (just like you normally would).
However, if you are running an older version of Windows (Build 18945 or less), you will need to get the IP address of the Linux host VM (or update to the latest Windows version).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With