• Register
0 votes
108 views

Problem :

Getting bellow error
java.net.connectexception connection timed out no further information
6 5 3
6,930 points

Please log in or register to answer this question.

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 {
9 7 4
38,600 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.

11 5 2
3,890 points

Related questions

0 votes
1 answer 57 views
57 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 611 views
611 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
1 answer 5 views
5 views
Problem: Why I got the error : java.net.connectexception connection refused no further information
asked Mar 25 MUHAMMAD MUNEEB 83k points
0 votes
1 answer 27 views
27 views
Solve this.
asked Dec 26, 2020 TeamScript 13.5k points
1 vote
1 answer 2 views
2 views
Problem: Please help me. How can I solve it? java.net connectexception connection timed out connect
asked Mar 25 MUHAMMAD MUNEEB 83k points
1 vote
1 answer 4 views
4 views
Problem: Any ideas on what I need to do to fix this? java.net.connectexception: connection timed out: connect
asked Mar 25 MUHAMMAD MUNEEB 83k points
0 votes
1 answer 6 views
6 views
What is the reason and how can i solve this?
asked Dec 18, 2020 TeamScript 13.5k points
0 votes
1 answer 3 views
3 views
Problem: Please help me fix this dilemma: io netty channel connecttimeoutexception connection timed out
asked Apr 7 rakib1 51.5k points
0 votes
1 answer 2 views
2 views
Problem: Can someone please help me fix this?error: connection timed out after 20 seconds of inactivity
asked Mar 27 ashik 12.9k points
1 vote
2 answers 186 views
186 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