Started a local server in my computer with IP 127.0.0.1 listening on port 3000.
However, I am unable to access it via my android app when I run the emulator on android studio. I got a timeout error from my app's networking library, so it is not making connection.
If you're using Android Studio to run the emulator, then localhost of your host computer will be mapped to the IP address, 10.0. 2.2 , inside the emulator. If you're using other programs to run the emulator, then you may need to consult the documentation associated with those programs.
Use the IP address 10.0.2.2
. You can read more at here.
On each Android emulator Android Studio runs a router for it in order to isolate the emulated device from your development system. Thus in order to access a local server running on your development system (your laptop, desktop, etc) you must use the special IP of 10.0.2.2 and the port the server is listening on. To learn more read this page.
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