I have a HTTP server working on my android emulator listening to port 8080. How can I connect to it from same PC's browser? I tried 127.0.0.1 but it couldn't connect.
Asked
Active
Viewed 4,078 times
6
-
Possible duplicate : http://stackoverflow.com/questions/1720346/how-to-get-the-android-emulators-ip-address – EvZ Feb 04 '13 at 10:08
2 Answers
17
You have to enable port forwarding in adb
. For example:
adb forward tcp:8080 tcp:8080
This will forward incoming connections to localhost TCP/8080 to the emulator TCP/8080.
Here's the reference.

m0skit0
- 25,268
- 11
- 79
- 127
-
1The note about localhost is useful. To be super clear, after forwarding, you can browse to `http://127.0.0.1:8080` on your PC and you will see whatever is being served up via port 8080 on the emulator (in my case I was listening to HTTP requests and serving up HTML which showed up on my laptop just as expected - super cool and super useful!). – Eric Mutta Mar 24 '20 at 02:21
-2
You can use 10.0.2.2 to access your actual machine, it is an alias set up to help in development.

Kanaiya Katarmal
- 5,974
- 4
- 30
- 56