I've started android emulator app and trying to open from embeded browser locally started web-site, but local dns name (from /etc/hosts) is not resolved. Is there any option to enable local resolving?
3 Answers
Refer this URL. The issue is 127.0.0.1 is not the correct IP for accessing local server sites on emulator.
http://localhost:8080/MyTestPage.html // URL to use in computer browser
http://10.0.2.2:8080/MyTestPage.html // URL to use in emulator browser
However, you need to do some configuration changes as suggested in the URL.

- 8,662
- 2
- 26
- 37
-
Seems like the site you've linked to is not available anymore. – Fabian Lauer May 07 '18 at 14:02
Here's how to access a locally hosted website in the Android emulator.
Use IIS/Apache to host the application.
For some obscure reason, Android Virtual Device would not let you connect to the development server created by Visual Studio.Once you host the application, use your IP address as the web address to connect to the local website. "localhost" just won't work with the AVD. Just go to the command prompt and type ipconfig to get your local ip address. You should be looking for IPv4 Address
Here's Android AVD connecting to Apache (XAMPP)
Here's connecting to IIS
Good Luck everyone and happy testing!!

- 19,542
- 20
- 83
- 128
-
Using Android Studio, this worked for me on both a Genymotion and an AVD emulator; having my project hosted either on my computer or my virtual host, However it's weird it's not working with 10.0.2.2:8080. Many people insist that's the correct address. – Juan José Melero Gómez Jun 12 '15 at 22:09
You should specify your local ip address in browser, something like 192.168.xx.xx

- 43,261
- 10
- 79
- 89
-
i have dev. site on 127.0.0.1 - tried with domain name and ip 127.0.0.1 - emulator does not resolving any of both. – Alexey Poimtsev Jul 14 '10 at 18:41
-
it looks like emulator uses preconfigured dns server and ignoring any local sites :( – Alexey Poimtsev Jul 14 '10 at 18:42
-
Exactly. I also hav dev site on 127.0.0.1. Emulator can't connect to 127.0.0.1. That's why I just specify my local ip like that 192.168.xx.xx. This way emulator connects to my dev site correctly. – Fedor Jul 14 '10 at 23:17
-
1What about when you use virtual hosts to map different development sites? Any way to just edit the hosts file? – tonyhb Aug 24 '11 at 10:01
-