Guest OS Web Server Access
In the latest project in my new role, I am developing with Angular 4/5 on Windows 10 hosted within Parallels on a Mac. Yes, I have a Mac now. What is the world coming to?
I needed to test some new functionality of the web app in a variety of operating systems and browsers. I figured it shouldn’t be too difficult to access the web server on the Guest OS, since the Apple mantra has always been “it just works”. Unfortunately, it didn’t just work.
There are numerous entries in the search results about trying to access the web server on the Host OS from the Guest OS, but I needed to do the opposite. I need to access the web server on the Guest OS from the Host OS. I eventually pieced together the following steps, in case you run into the same issue.
If this helps you or if you have additional troubleshooting tips, leave a comment below.
I needed to test some new functionality of the web app in a variety of operating systems and browsers. I figured it shouldn’t be too difficult to access the web server on the Guest OS, since the Apple mantra has always been “it just works”. Unfortunately, it didn’t just work.
There are numerous entries in the search results about trying to access the web server on the Host OS from the Guest OS, but I needed to do the opposite. I need to access the web server on the Guest OS from the Host OS. I eventually pieced together the following steps, in case you run into the same issue.
Bridged Mode Networking
To make it easier to access the Guest OS web server from not just the Host OS, but other machines, I enabled “Bridged Mode” networking for the Windows 10 virtual machine. The Windows box now gets an IP address directly from my LAN instead of being NATed through the macOS Host.Open Port in Firewall
The application is being served on a non-standard port for HTTP, so I had to open that port in the Windows 10 firewall settings. The port to open will depend on the settings for your project.Listen on All Interfaces
By default, Angular only listens on the localhost interface (see host option for ng serve). This may be due to the fact that in Windows, localhost is a separate network interface, but this means that, at least in Windows, Angular will not receive requests from other machines – including, but not limited to, the Host OS. I added “--host 0.0.0.0
” to the ng serve command for the app to force Angular to listen on all network interfaces.Conclusion
I can now access my Windows 10 Guest virtual machine from the macOS Host to test in Safari. More than that, I can also access the Windows 10 VM from other devices on my LAN including my phone for testing in a mobile browser.If this helps you or if you have additional troubleshooting tips, leave a comment below.