Buy @ Amazon

Accessing localhost server in host machine from Genymotion Emulator

Genymotion runs on Virtualbox, and the default network configuration is “Host-Only”. Host-only essentially means all network requests within Genymotion are routed through the host machine. Put other way, the host becomes the network proxy for Genymotion.

Now should we run any service in the host machine that Genymotion needs to make use of, all we need to do is get the host machine ip address as seen by Genymotion Virtualbox. From host machine perspective, the name of the Genymotion’s network will be vboxnet0.

So just run the below mentioned command in your mac terminal, and you’d see the output something like below [It is important that you’re running the Genymotion before you run the command in the terminal]:

ifconfig vboxnet0
vboxnet0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
    ether 0a:00:27:00:00:00
    inet 192.168.56.1 netmask 0xffffff00 broadcast 192.168.56.255

The init value (in my case 192.168.56.1) is the ip address of the host m/c as Genymotion see it.

Side note: If you’d want to run the local project in a light weight python web-server, go to the root of your local project in your host server in your terminal and run the command below (assuming you’ve not removed or have have python in your mac):
$ python -m SimpleHTTPServer

Happy coding!