java.net.ConnectException : Connection refused


In my case, I was running a server socket on 127.0.0.1 on port xyz, and trying to get my clients to connect to it. It worked on one ubuntu machine, but failed to work on another.


serverSocket = new ServerSocket(serverPort, 500, Inet4Address.getByName("127.0.0.1"));

I changed this to 

serverSocket = new ServerSocket(serverPort, 500, Inet4Address.getLocalHost());

Thats it, started to fly again… 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s