How to connect to my http://localhost web server from Android Emulator
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.
Use 10.0.2.2
for default AVD and 10.0.3.2
for genymotion.
The localhost refers to the device on which the code is running, in this case the emulator.
If you want to refer to the computer which is running the Android simulator, use the IP address 10.0.2.2 instead.
You can read more from here.
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.