0

I am not able to connect to an remote known server through Java code; java.net.NoRouteToHostException: No route to host exception occurs when connection is tried.

But strangely, I am able to connect to same server through ssh.

Details: Simple Java client when tries to establish connection with Java standalone server, while conneting the exception occurs at following statement:

Socket socket = new Socket(ServerIP ServerPort);

The port needed is open on server so that externally request can come in.

Again the following is returns false

InetAddress.getByName(SERVER_IP).isReachable(1000)

The Server is running on Fedora, Java 5.

FYI: Java cannot resolve DNS address from AIX: UnknownHostException is almost same to my question, but somehow this is neither AIX nor dns related; moreover I feel the issue to be more of Network or firewall issue.

Please guide me.

2 Answers 2

1

This is the error you'd expect from a host being firewalled. Can you telnet to the same port on that IP?

4
  • you guessed it right, I cannot telnet, although the netstat show me that the port is open for listening. netstat -pan | grep 5014 tcp 0 0 :::5014 :::* LISTEN 6212/java
    – nilesh
    Sep 8, 2009 at 6:00
  • netstat will only tell you whether the port is listening, not if it's firewalled. It's entirely possible there's something in between blocking traffic, or a iptables/pf/ipfilter on the host, none of which would show up in netstat.
    – Cian
    Sep 8, 2009 at 8:11
  • Recently I checked, I am able to telnet certain ports (the port on which mysql-cluster is running) ; but not any other such as 5000 mentioned earlier. I even tried to use some other ports but to no use.
    – nilesh
    Sep 8, 2009 at 16:05
  • Sounds like a firewall issue. E_CONTACT_NETWORK_ADMIN
    – Cian
    Sep 8, 2009 at 16:50
0
  1. The Socket constructor should only attempt to resolve if the hostName is null, and then it tries to resolve the local host. Is your /etc/hosts file set up properly?

  2. What does the following code return? (Please use the host name, not the ip ).

    System.out.println(InetAddress.getByName(hostName));
    

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .