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?
ConnectException: Connection refused: 1) First try to ping the destination host, if the host is ping-able it means the client and server machine are in the network. 2) Try connecting to server host and port using telnet. If you are able to connect means something is wrong with your client code.
0.1 (loopback address). So your client is trying to connect to any of the non-loopback addresses of your machine, while your server is listening only on the loopback address . So, no connection can be established. The solution to this problem is that connect to the same end point your server is listening on.
Ans: The Java connection refused is a case of a user trying to connect on TCP port but not able to access. There are many reasons, here are some possible causes why Java net ConnectException connection refused error occur: The server is not working. The client is not in the network.
java.net.ConnectException: Connection refused: connect is one of the most common networking exceptions in Java. This error comes when you are working with client-server architecture and trying to make TCP connection from the client to the server.
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
in android
Replace: String webServiceUrl = "http://localhost:8080/Service1.asmx"
With : String webServiceUrl = "http://10.0.2.2:8080/Service1.asmx"
Good luck!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With