Android – java.net.ConnectException: localhost/127.0.0.1:8080 – Connection refused

android

I am using xampp apache server to serve resources to the application from my machine. But i am getting the above error.

I got something on the google. pointing towards possible solution here
http://groups.google.com/group/android-beginners/browse_thread/thread/599a06416fb37b4a

What is the solution for the above problem?

Best Answer

Since you have not specified you are connected to a server from the device or emulator so I guess you are using your application in the emulator.

If you are referring your localhost on your system from the Android emulator then you have to use http://10.0.2.2:8080/ Because Android emulator runs in a Virtual Machine therefore here 127.0.0.1 or localhost will be emulator's own loopback address.

Refer: Emulator Networking