• Register
Welcome to Kodlogs, programming questions and answer website.
0 votes
6 views

Problem :

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

1 Answer

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 {
by (20.3k points)  
...