[android] How to connect to my http://localhost web server from Android Emulator

What can I do in the Android emulator to connect it to my localhost web server page at http://localhost or http://127.0.0.1?

I've tried it, but the emulator still takes my request like a Google search for localhost or worse it says that it didn't found the page while my web server is normally running.

This question is related to android android-emulator localhost loopback-address

The answer is


Try http://10.0.2.2:8080/ where 8080 is your port number. It worked perfectly. If you just try 10.0.2.2 it won't work. You need to add port number to it. Also if Microsoft IIS has been installed try turning off that feature from control panel (if using any windows os) and then try as given above.


I needed to figure out the system host IP address for the emulator "Nox App Player". Here is how I figured out it was 172.17.100.2.

  1. Installed Android Terminal Emulator from the app store
  2. Issue ip link show command to show all network interfaces. Of particular interest was the eth1 interface
  3. Issue ifconfig eth1 command, shows net as 172.17.100.15/255.255.255.0
  4. Begin pinging addresses starting at 172.17.100.1, got a hit on `172.17.100.2'. Not sure if a firewall would interfere but it didn't in my case

Maybe this can help someone else figure it out for other emulators.


Another workaround is to get a free domain from no-ip.org and point it to your local ip address. Then, instead of using http://localhost/yourwebservice you can try http://yourdomain.no-ip.org/yourwebservice


If you are in windows you can go to simbol system and write ipconfig and check what ip is assigned to your machine.


I do not know, maybe this topic is already solved, but when I have tried recently do this on Windows machine, I have faced with lot of difficulties. So my solution was really simple. I have downloaded this soft http://www.lenzg.net/rinetd/rinetd.html followed their instructions about how to make port forwarding and then successfully my android device connected to make asp.net localhost project and stopped on my breaking point.

my rinetd.conf file:

10.1.1.20 1234 127.0.0.1 1234
10.1.1.20 82 127.0.0.1 82

Where 10.1.1.20 is my localhost ip, 82 and 1234 my ports Also I have craeted bath file for easy life yournameofbathfile.bat, put that file inside rinedfolder. My bath file:

rinetd.exe -c rinetd.conf

After starting this soft, start your aps.net server and try to access from android device or any device in your local network(for example Computer ABC starts putty) and you will see that everything works. No need to go to router setting or do any other complicated things. I hope this will help you. Enjoy.


according to documentation:

10.0.2.2 - Special alias to your host loopback interface (i.e., 127.0.0.1 on your development machine)

check Emulator Networking for more tricks on emulator networking.


10.0.2.2 is alis made for base machine localhost.

port number same : 1521 no need to change

abs works fine for me ..


For My Mac OS mountain Lion device :

http://10.0.2.2:8888

Works perfect !


If you using Android Emulator :

You can connect to your Pc localhost by these IPs : 10.0.2.2:{port of your localhost} => if you set your machine port in xamp you must use that port . In my case 10.0.2.2:2080

enter image description here

enter image description here

Also you can use your network adapter IP .In CMD write ipconfig and find your adapter ip address :

enter image description here

enter image description here

If emulator can not connect to this IPs close the emulator an open it by cold boot from AVD Manager :

enter image description here

If you using Genymotion :

You can connect to machine localhost by this IP : 10.0.3.2:{port number} Or your adapter IP address as I explained above: in my case : 192.168.1.3:2080


I used 10.0.2.2 successfully on my home machine, but at work, it did not work. After hours of fooling around, I created a new emulator instance using the Android Virtual Device (AVD) manager, and finally the 10.0.2.2 worked.

I don't know what was wrong with the other emulator instance (the platform was the same), but if you find 10.0.2.2 does not work, try creating a new emulator instance.


You can actually use localhost:8000 to connect to your machine's localhost by running below command each time when you run your emulator (tested on Mac only):

adb reverse tcp:8000 tcp:8000

Just put it to Android Studio terminal.

It basically sets up a reverse proxy in which a http server running on your phone accepts connections on a port and wires them to your computer or vice versa.


Use 10.0.2.2 for default AVD and 10.0.3.2 for .


Examples related to android

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How to implement a simple scenario the OO way My eclipse won't open, i download the bundle pack it keeps saying error log getting " (1) no such column: _id10 " error java doesn't run if structure inside of onclick listener Cannot retrieve string(s) from preferences (settings) strange error in my Animation Drawable how to put image in a bundle and pass it to another activity FragmentActivity to Fragment A failure occurred while executing com.android.build.gradle.internal.tasks

Examples related to android-emulator

flutter run: No connected devices How to remove the Flutter debug banner? Android Studio AVD - Emulator: Process finished with exit code 1 Android Studio Emulator and "Process finished with exit code 0" Run react-native on android emulator ERROR Android emulator gets killed Error while waiting for device: Time out after 300seconds waiting for emulator to come online Unfortunately Launcher3 has stopped working error in android studio? updating Google play services in Emulator Android Studio emulator does not come with Play Store for API 23

Examples related to localhost

Xampp localhost/dashboard Set cookies for cross origin requests Invalid Host Header when ngrok tries to connect to React dev server How to turn on/off MySQL strict mode in localhost (xampp)? What is IPV6 for localhost and 0.0.0.0? How do I kill the process currently using a port on localhost in Windows? How to run html file on localhost? Can't access 127.0.0.1 Server http:/localhost:8080 requires a user name and a password. The server says: XDB How to solve ERR_CONNECTION_REFUSED when trying to connect to localhost running IISExpress - Error 502 (Cannot debug from Visual Studio)?

Examples related to loopback-address

How to connect to my http://localhost web server from Android Emulator