In VirtualBox, how can I access host localhost from guest (Visual Studio Dev Server from IE7 testing VM)?
Host OS is Win7 running MyApp in the Visual Studio Development Server, bound to localhost:51227, VM is VirtualBox configured with NAT. Guest OS is Win XP with IE7 installed. My goal is to debug MyApp (running on host) from within IE7 (running on guest).
Visual Studio Development server only binds to the loopback network device (i.e. localhost). It does not bind to the external IP address of my host.
I've tried access 10.0.2.2:51227 from IE7 on the guest (and confirmed that 10.0.2.2 is the gateway address using ipconfig), but it appears that 10.0.2.2 binds to the external IP of the Host, NOT the loopback IP (localhost), so this does not work.
Any suggestions?
Solution 1:
The simplest solution for me was to use SPI Port Forward on the Host to allow access to my localhost-only service from an external network interface:
- Download SPI Port Forward and Run on the Host (no installer, download is a naked exe)
- Important: Windows Firewall will ask if SPI Port Forward is allowed to access Public networks. Check the box to allow access from public networks.
- Set Local Port to 8888 (or whatever you want), Remote Host to localhost, Remote port to the port of the target service on the host (in my case 51227, as VSDS is running on port 51227), and click "Activate"
- Access 10.0.2.2:8888 from the guest.
Note: If 10.0.2.2 doesn't work, run cmd on the guest to bring up a command line, and use 'ipconfig', and use the default gateway address, but VirtualBox currently defaults to 10.2.2.2 for this, so its a safe bet.
It should be noted that this configuration will allow EXTERNAL IP ACCESS TO VSDS, so use with caution... of course, this could be useful if you wanted to debug mobile phone support or something too.