Access a host service from within a VM
This should serve as a reminder to me of how to use services or websites that I’m developing on MacOS from within a windows VM. This is useful when the back-end services are cross-platform, but needs to be called from windows-specific software.
The VM I’m currently using is Parallels. A helpful document for this was this gist.
- Ensure that the service or website isn’t just listening on localhost, but rather on 0.0.0.0. In an aspnet core service for example this can be configured by adding “applicationUrl”: “http://0.0.0.0:5000;https://0.0.0.0:5001" to the launchSettings.json.
- Access the url in the VM using either the Mac’s hostname, or the name that computers on the local network can access it located in System Preferences > Sharing, or the IP address 10.211.55.2. The gist link mentioned earlier explains where this IP address comes from.
I followed a couple of false trails — people suggested using the bridged networking mode of the VM for example and using port forwarding. This turned out to be unnecessary and the default shared network is acceptable.