How to access a local host or service from a virtual device?
2 years ago • Updated
> Note > The following methods only applies if Genymotion Desktop and your server/service run on the same host machine.
If the application you are developing needs to connect to a local server or service, such as a REST service, you may need your virtual device to access your local host.
With VirtualBox
To do this, you can use the IP address 10.0.3.2 from the virtual device to reach your service or server. IP 10.0.3.2 is a VirtualBox alias to your host loopback interface (i.e., 127.0.0.1 on your host machine).
For example, if you run a service on your host machine which listens to localhost:1234, it can be accessed from the virtual device using the IP 10.0.3.2:1234.
With QEMU
Unlike VirtualBox, there is no loopback interface when using QEMU. However, it is possible to use
adb reverse to bind a virtual device local port to a host local port.
For example, if you run a service on your host machine that listens to localhost:1234, then use the command:
adb reverse tcp:1234 tcp:1234
This will bind the virtual device local TCP port 1234 to your host machine local TCP port 1234. Thus, the service can be accessed from the virtual device using the IP localhost:1234.
Was this article helpful?
- Yes
- No
15 out of 31 found this helpful
Need more help? Request Technical Support
Return to top
Related articles
- How to connect to a Genymotion Desktop virtual device remotely with ADB?
- The VirtualBox DHCP server has not assigned an IP address to the virtual device
- How to share folders with Genymotion Desktop host machine?
- Unable to start the Virtual Device
- I can't find Google Play Store. Where is it?