Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.net.ConnectException - Connection Refused Android Emulator

I have an android emulator I'm running from eclipse and just trying to connect to a simple socket server I wrote in .NET (c#).

The server is running on the same machine on port 4505. I am able to telnet (through PuTTy) to the server and it works just fine, but when I try to connect to the server with the android emulator I get a: java.net.ConnectException - localhost/127.0.0.1:4505 - Connection refused at org.apache.harmony.luni.net error.

I'm assuming this is because the emulator is on a different subnet or something? If that were the case though I would think I would be getting a different error that would be caught in the UnknownHostException catch block...

like image 765
Kyle Avatar asked Aug 16 '10 20:08

Kyle


People also ask

How do I resolve Java net ConnectException Connection refused connect?

net. 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.

What does Java net ConnectException mean?

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.

What does Java net ConnectException Connection Refused no further information mean?

net. ConnectException: Connection refused: connect. It's quite possible that either you are providing incorrect host port combination or earlier host port combination has been changed on the server side. Check the latest configuration on both client and server side to avoid connection refused exception.


1 Answers

According to Emulator Networking IP 10.0.2.2 should be used instead of localhost/127.0.0.1.

like image 75
Grzegorz Gierlik Avatar answered Sep 27 '22 20:09

Grzegorz Gierlik