I am trying to test web application in Android 2.3.3 browser. Connection using http://10.0.2.2 results "web page is unavailable". Nothing found in Android Studio documentation.
Does anyone run into the same problem? How did you solve it?
As you've learned, when you use the emulator, localhost ( 127.0. 0.1 ) refers to the device's own loopback service, not the one on your machine as you may expect. You can use 10.0. 2.2 to access your actual machine, it is an alias set up to help in development.
To access the server from itself, use http://localhost/ or http://127.0.0.1/ . To access the server from a separate computer on the same network, use http://192.168.X.X where X.X is your server's local IP address. You can find the sever's local IP address (assuming it's Linux) by running hostname -I . 127.0.
Each instance of the Android emulator runs behind a virtual router/firewall. You can find a list of IP addresses used in the network address space here. Among these IP addresses, you will find a special alias to your host computer's loopback interface (aka localhost). This alias is 10.0.
You're going to need to connect to your computer's IP.
If you're on Windows open CMD and type ipconfig this will give you your local IP.
If you're on Linux or OSX open terminal and use the ifconfig command.
Since the emulator is a full Android device it has its own network and doesn't use the same hosts file that your machine has. Along with its own IP.
Edit: Grammar fix.
I use my local ip for that i.e. 192.168.0.1 and it works. Verify your local IP.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With