• Register
search
Log In
0 votes
60 views

Problem :

Getting bellow error
java.net.connectexception connection timed out no further information
6.9k points

2 Answers

0 votes

Solution :

1) Firstly try to ping the destination host, if the host is pingable it means client and server machine are in the same network.

2)Try to connect to the server host and port using telnet. If you are able to connect it means something is wrong with your client code. Also, by observing telnet output you will come to know whether the server is running or not or server is disconnecting the connection.

3)For a quick fix catch ConnectException in your main try-catch block like bellow:

try {
    // connect, write, and read ...
} catch (ConnectException ce) {  
    System.out.println("You caught a ConnectException.");
} catch (IOException e1) {       
    // TODO Auto-generated catch block
    e1.printStackTrace();
} finally {
36.1k points
0 votes

Connect is the most common networking exception in java. This error encounter when you are working with client-side architecture and trying to establish a TCP connection from the client to the server.

Reasons:

This is a clear case that client is trying to connect to TCP port but not able to successfully establish. Here are some couple of reasons;

Client and server, either or both are not in-network:

This is possible that both the client and server are not connected to LAN or the internet or any other network.

The server is not running:

The second most common reason is that the server is down. In this case, you also get error java.net.ConnectException. Connection refused error.

The server is not listing to port:

One reason of encounter this error is that the server is running but not listing to any port. It is very hard to figure out this case until you think about it and verify the connection.

Solution:

First, try to a ping destination host, if the host is pingable then it means that client and server machines are pingable.

Try to connect to the server host and port by using telnet. If you can connect then it means that something is wrong with your client mode. By observing telnet output you will come to know that the server is running or not and the server is disconnecting the connection.

I hope this will help to solve your problem.

3.9k points

Related questions

0 votes
1 answer 38 views
38 views
Problem : I am getting bellow error java.net.connectexception: connection refused: no further information:
asked Oct 31, 2019 peterlaw 6.9k points
0 votes
2 answers 176 views
176 views
Problem : Today I was testing Server and Client code on different machine. Both were on same Wi-fi network. I created clients and got this exception for many threads : java.net.ConnectException: Connection timed out: no further information
asked Oct 23, 2019 peterlaw 6.9k points
1 vote
2 answers 104 views
104 views
Problem : Getting bellow Minecraft error io.netty.channel.abstractchannel$annotatedconnectexception connection timed out no further informa
asked Nov 8, 2019 peterlaw 6.9k points
1 vote
2 answers 26 views
26 views
Problem: I am able to login through webservices api to particular account on 'Oracle on demand'. When i tries to call 'accountQueryPage' method of the stub class (Stub class is generated with help Account.wsdl file), i got the following exception java.net.SocketException: Software caused connection abort: recv failed Can anyone give me some pointers.
asked Mar 27 LizzyM 5.7k points
2 votes
1 answer 24 views
24 views
Problem: I am able to login through webservices api to particular account on 'Oracle on demand'. When i tries to call 'accountQueryPage' method of the stub class (Stub class is generated with help Account.wsdl file), i got the following exception java.net.SocketException: Software caused connection abort: recv failed Can anyone give me some pointers.
asked Mar 24 LizzyM 5.7k points