How to access localhost from a Genymotion android emulator?

AndroidEmulationMampGenymotion

Android Problem Overview


I can not figure out how to access localhost from a Genymotion android emulator. By the way, Im using MAMP.

Android Solutions


Solution 1 - Android

Update

After genymotion update to 2.2 you can use 10.0.3.2, ref

Another approach

To access your localhost through Genymotion is using your PC IP address. to get your IP address go to:

start -> cmd -> ipconfig

then search for IPv4, copy the IP and paste it in your URL. It should looks like the following:

String YourURL = "http://192.168.0.106:8888/your_script_location.php";

Hope this works too for you, give me a feedback.

P.S: if it didn't work, turn off the firewall and any anti-virus application you have in your PC.

Solution 2 - Android

you need this structure

Genymotion

http://10.0.3.2/

Default AVD

http://10.0.2.2/

the http it's very important and the port it's for default It depends on your server.

you can check this url in your browser the smartphone

enter image description here

Solution 3 - Android

The IP returned by ipconfig dit not work for me. However 10.0.3.2 worked for me even though the IP address in the Wifi setting is 10.0.3.15.

Genymotion 2.2.0

Solution 4 - Android

it works for me by using http://192.168.56.1:8080

to know your IP just use the following command

  • for (mac and linux) ifconfig vboxnet0
  • windows command ipconfig vboxnet0

and make sure the port is collect.

I got the answer from : here

Solution 5 - Android

Intro:

>Long story short, Genymotion is running on Virtualbox, and the default network configuration is “Host-Only.” This method essentially emulates a physical network that is shared by your Genymotion VM (the emulator) and your host machine. The name of the network is vboxnet0, and if you run “ifconfig vboxnet0” (or “ipconfig vboxnet0” if running Windows) on your host machine, you should receive the IP address of your host on the vboxnet0 network. The default IP is most likely 192.168.56.1.

Solution:

>This is the IP address to use when accessing your host machine from the Genymotion emulator. For my Rails app, this meant calling “192.168.56.1:3000” instead of “10.0.2.2:3000.”

http://bbowden.tumblr.com/post/58650831283/accessing-a-localhost-server-from-the-genymotion

Solution 6 - Android

Genymotion! It works for me using IP 10.0.3.2 but depends on your localhost port. Apache it will be just IP and Tomcat with default port 8080. Here I take screenshots.

1. Apache Screenshot

Genymotion Apache

2. Tomcat Screenshot

enter image description here

Hope this is helpful. Thanks!

Solution 7 - Android

  1. run xampp(def 127.0.0.1:80) and go to Control Panel\All Control Panel Items\Network and Sharing Center
  2. select connection

enter image description here

Solution 8 - Android

When i used genymotion in my ubuntu

i used the ip address of the virtual machine as local host and it worked .

in virtual box goto file > preferences > network > select host only network and select adapter tab copy the ipv4 address and use it instead of localhost ...

like http://192.168.56.1/qrstuff/json/

Solution 9 - Android

Check your Internet Connection on PC first, then Turn on Wifi in your Genymotion Emulator Device

After goto Cmd by Pressing ctrl+r then type Cmd and hit enter you will see an command line window

type ipconfig and hit enter...

here you can see your ipv4 address type it in your Genymotion Emulator Device's Browser now you can connect to your local webserver....

Solution 10 - Android

In my case 10.0.3.2 didn't work. I changed to virtual box host-only network : 192.168.128.2 it works. You have to try other virtualbox adapters IP if it doesn't work with 192.168.56.1. My environment is behind a corporate proxy and I was running an embedded undertow server. Hope it helps.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionmownierView Question on Stackoverflow
Solution 1 - AndroidCoderjiView Answer on Stackoverflow
Solution 2 - AndroidDavid HackroView Answer on Stackoverflow
Solution 3 - AndroidSydneyView Answer on Stackoverflow
Solution 4 - AndroidikuchrisView Answer on Stackoverflow
Solution 5 - AndroidBrainsView Answer on Stackoverflow
Solution 6 - AndroidMadan SapkotaView Answer on Stackoverflow
Solution 7 - AndroidsirmagidView Answer on Stackoverflow
Solution 8 - AndroidAmeen MaheenView Answer on Stackoverflow
Solution 9 - AndroidKarthickView Answer on Stackoverflow
Solution 10 - AndroidIldiXView Answer on Stackoverflow