I started a local http server on Android and it can be reached by other computers in the same local network. But if I try to access this server using opera on the same phone, it won't work. So this means we are not able to access localhost on Android? Thanks!
Asked
Active
Viewed 1.2k times
8
-
Duplicate of [test the localhost in android emulator](http://stackoverflow.com/questions/2234742/test-the-localhost-in-android-emulator) – Christopher Orr Dec 25 '10 at 19:44
-
1Since I am using a device, it is not duplicated. I also tried 10.0.2.2 but still get nothing. – echo Dec 30 '10 at 20:58
-
1Why did you accept a **factually incorrect** answer which did not solve your problem??? – Chris Stratton Jun 18 '13 at 15:42
-
Because my comment in that answer explains it was my fault. – echo Jun 18 '13 at 22:41
3 Answers
6
You shoud use next IP 10.0.2.2

Yaroslav Boichuk
- 1,763
- 20
- 31
-
1I don't think so. I am using a real device, not emulator. Thanks for the answer though. – echo Dec 26 '10 at 05:05
-
2Btw, you may try start a http server using an app called kWS, and access it from the same phone browser. It always fails on my phone. – echo Dec 30 '10 at 23:20
-
1It was my fault! Opera on my device cannot access localhost, but the default browser can. – echo Jan 03 '11 at 02:22
-1
Try to use your ip address in your pc (ipconfig to see the ip address for your pc)
IPv4 Address. . . . . . . . . . . : 192.168.1.12
So, use: 192.168.1.12:3000

dwitvliet
- 7,242
- 7
- 36
- 62
-1
Just check this http://developer.android.com/guide/developing/devices/emulator.html#networkaddresses
If ur app running in localhost:3000, then try to use as 10.0.2.2:3000 in your android emulator

Thillai Narayanan
- 4,766
- 5
- 32
- 39
-
2No, this is not correct. 10.0.2.2 is for a server running on the machine hosting an emulator. The server in this question runs on the device itself. – Chris Stratton Jun 18 '13 at 15:43