Access host from Genymotion emulator
Asked Answered
F

5

45

I try to connect from my app to host using IP address 192.168.56.1, but without success. I checked in ipconfig and there is a Virtualbox connnection with above mentioned IP. Can someone help to fix it?

Flexible answered 27/8, 2013 at 10:48 Comment(1)
Weird, in my case 10.0.3.2 didn't work (connection refused) but the address given by Virtual Box vboxnet0 which was 192.168.56.1 worked normally. What could be the cause of it.Serve
H
110

try this ip address: 10.0.3.2 It should work

Hypotenuse answered 22/9, 2013 at 3:36 Comment(5)
Can someone explain the source for this this information, or explain the process on how identify this ip address?Affiant
I don't remember exactly how i found this out, but from the Android developer page, the android team use 10.0.2.2 as a default ip address for their avd emulator. And from genymotion, i went to settings and checked the wifi and saw ip address of 10.0.3.15 so i tried (with luck) with 10.0.3.2 and it workedHypotenuse
This answer is quite vital, because things get more complicated: Apparently your localhost 192.168.56.0 ip address can change! Mine is now 192.168.56.102, while the 10.0.3.2 is still valid as your localhost. This happened to me, where the emulator got the 192.168.56.101 address, and the second emulator got 192.168.56.103.Mania
Weird, in my case 10.0.3.2 didn't work (connection refused) but the address given by Virtual Box vboxnet0 which was 192.168.56.1 worked normally. What could be the cause of it.Serve
It still works fine - but I find it odd that Genymotion has not even mentioned this in their FAQ or documentationBlinkers
R
7

I had the same problem as OP, switching to Bridged for Adapter 2 rectified the problem for me.

VirtualBox > Settings > Network  > Adaptor 2

Attached to: Bridged Adapter
Name: en0: Wi-Fi (airport)
Resilient answered 26/1, 2014 at 19:6 Comment(1)
I had no internet connection before applying this. But after upgrading to Windows 10, there is no longer anything to select in Bridged Adapter. I banged my head against the wall for a month but found no answer. I uninstalled and reinstalled both Virtualbox and Genymotion but it didn't work. Do you know why?Caniff
U
3

Try this to verify (works for me)…

On your host start up the simplest web server in some random directory:

$ python -m SimpleHTTPServer
Serving HTTP on 0.0.0.0 port 8000 …

Now in your genymotion device startup Chrome and browse to http://192.168.56.1:8000 and you should see a webpage listing the contents of the directory you stared the SimpleHTTPServer in.

This shows that connecting from guest to host on the IP address you indicated works. There must be some other issue.

Upstart answered 18/9, 2013 at 19:10 Comment(0)
O
0

Even I had the same issue and here is the solution:
Your computer's internet should be "ON" while connecting to database
If you specify port number but don't ON internet, it won't work.
However if you don't specify port number and computer's internet is ON, you should get the output.

Here is the output without internet in one of my program Output without internet

And here is the output with internet

Output with internet

Also make sure that WIFI is on in the Genymotion emulator and its working. You can check it by opening browser inside emulator and opening any web page address.

Please comment if further help is required.

Owe answered 16/3, 2014 at 5:45 Comment(0)
J
0

It's actually really easy to find the IP address of your host!

Linux (and Mac, presumably)

Simply open the Terminal (Ctrl+Alt+T) and run ifconfig. The IP address can be found in the information for an interface named vboxnet<number>.

Windows

Simply open CMD (Windows logo key+R, "cmd") and run ipconfig. The IP address can be found in the information for an interface with something like 'vbox' or 'VirtualBox' in the name.


There may be more than one interface listed that matches these criteria, so you'll have to try which is the right one.

Juryman answered 27/5, 2016 at 8:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.