Last Updated: February 25, 2016
·
11.39K
· mklickman

Access Localhost in Genymotion Simulators

Genymotion?

A few days ago I stumbled upon the Genymotion Android simulator, via this recently-released Treehouse project. I won't get into the specifics of it (you can check out the Genymotion site for the details), but it's so far the best solution for simulating an Android device that I've found - short of having a physical device, that is.

The Web Developer's Conundrum

As a web developer, I run my projects locally while I'm developing them; not an uncommon occurrence among developers. Normally I'll access my sites in-browser at an address like "http://0.0.0.0:3000" (Rails), or "http://127.0.0.1:9000" (Grunt/Node); the basic [IP]:[port] pattern that many of us are used to using across a local wifi network. With Xcode's built-in iOS simulator, you can enter those local addresses as-is and it will take you to your site (it should, at least). With Genymotion, however, there's a trick.

So What's the Trick?

With Genymotion, you create device-sepecific virtual machines, which run on top of the VirtualBox host (your computer). From the perspective of the virtual Android device, the host has its own IP address given by VirtualBox.

To access your local sites, simply replace the usual IP address you'd supply to your desktop browser (like "0.0.0.0" for a Rails site), and replace it with the default host IP address VirtualBox supplies, which is:

192.168.56.1

Which would result in a full URL (assuming a standard Rails server) of:

http://192.168.56.1:3000

Just replace the port number with whichever port your local server is running on, and your site should come right up.

I'm New Here

For me personally, the whole Genymotion/VirtualBox thing is all relatively new. If you have any additional knowledge you'd like to share, please do! I wouldn't be able to keep my family fed if not for the generosity of the development community when it comes to knowledge, so far be it from me to stifle that. Thanks for reading, hope I've been able to help!

1 Response
Add your response

Hi Marshall,
doesn't work for me.

over 1 year ago ·