9

String url = "http://127.0.0.1:8080/SampleServlet/TestServlet?"; URL url = new URL(con_url);

run in android emualator. but i got the connectexception 02-20 13:05:08.745: ERROR/Server Connection(230): java.net.ConnectException: /127.0.0.1:8080 - Connection refused

please reply me

Thanks

saravanan
  • 1,229
  • 6
  • 16
  • 17

1 Answers1

23

127.0.0.1 is a Android emulated device's own loopback interface.

In other words, you connect to android emulated device (not to your computer) by using 127.0.0.1.

To get connection to your machine with web-server use 10.0.2.2 or real machine IP address (if you have direct access from web).

Use command ipconfig(Windows)/ifconfig(Linux) to obtain your IP address.

Also see official docs or this!

Vlad Tsepelev
  • 2,056
  • 1
  • 21
  • 32
  • Actually, I suggest to modify link to point to official documentation - http://developer.android.com/guide/developing/tools/emulator.html#emulatornetworking – uthark Sep 22 '10 at 13:25