8

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!

echo
  • 789
  • 2
  • 12
  • 21

3 Answers3

6

You shoud use next IP 10.0.2.2

Yaroslav Boichuk
  • 1,763
  • 20
  • 31
  • 1
    I don't think so. I am using a real device, not emulator. Thanks for the answer though. – echo Dec 26 '10 at 05:05
  • 2
    Btw, 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
  • 1
    It 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
  • 2
    No, 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