43

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?

Konstantin Milyutin
  • 10,842
  • 11
  • 53
  • 77
  • 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. – xji Nov 17 '14 at 05:12

5 Answers5

108

try this ip address: 10.0.3.2 It should work

ngunha02
  • 1,689
  • 1
  • 18
  • 23
  • 2
    Can someone explain the source for this this information, or explain the process on how identify this ip address? – Lasse Samson Oct 10 '14 at 07:27
  • 5
    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 worked – ngunha02 Oct 10 '14 at 21:27
  • Thanks for the explanation! – Lasse Samson Oct 11 '14 at 09:49
  • 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. – Crypth Nov 13 '14 at 09:59
  • 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. – xji Nov 17 '14 at 05:12
  • It still works fine - but I find it odd that Genymotion has not even mentioned this in their FAQ or documentation – joensson Sep 19 '18 at 09:03
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)
Jimmy
  • 8,682
  • 24
  • 84
  • 144
  • 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? – Dariush Malek Aug 18 '15 at 11:38
2

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.

k s
  • 862
  • 8
  • 9
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.

Suraj Dubey
  • 496
  • 6
  • 11
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.

Community
  • 1
  • 1
user2428118
  • 7,499
  • 4
  • 41
  • 69