Tcp\Ip Client - Ehostunreach (No Route to Host)

TCP\IP client - EHOSTUNREACH (No route to host)

The no route error indicates that when the TCP connection was attempted, the connection failed because the underlying protocol software could not find a network node to network node route to the designated target node.

The fix is somewhat operating system dependent but it mainly requires you to set up your routing tables so that the device from which you are trying to connect is able to figure out how to reach the device to which you want to connect.

Normally you specify a gateway to which when you attempt to connect, the connection request goes out the network gateway to be resolved by other information technology devices such as routers, etc.

This looks to be an Android device, so the first thing is to make sure that you have connectivity whether WiFi or cell. Another would be to make sure that the WiFi or cell is turned on and operational.

The IP address you specify is normally within a private sub-net. So thing to check is is whether the device that you are trying to connect to is on the same sub-net that your device is on.

Here is a document on sub-nets and routing.

Quote from comment on Android by user destenson

A comment from user destenson on May-13-2017 adds this additional information specific to Android and the error messages provided in the posting.

Since this is android the first thing you need to look at is
permissions. 09-21 01:08:40.457: W/System.err(8536): at
libcore.io.BlockGuardOs.connect(BlockGuardOs.java:85)
indicates that
the connection was denied by policy on the device.

EHOSTUNREACH (No route to host) with Microsoft Azure and JTDS

Probably, it looks like a network connectivity problem, you could verify if:

  • The application has a successful connection to the Internet from the wifi network. Make sure that the WiFi or cell is turned on and operational.
  • The application outgoing public IP address has changed from your wifi network, you could add the new client IP to your Azure SQL server firewall, refer to this.
  • The port 1433 is blocked in your wifi network.

For more details, refer to this answer.

No route to host - connect(2) (Errno::EHOSTUNREACH)

You appear to be using the Ruby "Mail" library : http://rubygems.org/gems/mail

From my reading of the documentation, there is no configuration file. Instead, the library (optionally) configured in Ruby code.

If you don't do any configuration, the library defaults to using the mail server that is listening on "localhost" port 25. In that case, a "EHOSTUNREACH: No route to host" error most likely means that:

  • your computer either has a bad "hosts" entry for "localhost", or

  • the local host IP device is not properly configured.

Either way, is a system management problem not a programming problem. That's off-topic for SO ... and you haven't provided enough information to help us to diagnose / solve it anyway.

Otherwise, your code will somewhere contains something like this:

Mail.defaults do
delivery_method :smtp, { :address => "smtp.me.com",
:port => 587,
:domain => 'your.host.name',
:user_name => '<username>',
:password => '<password>',
:authentication => 'plain',
:enable_starttls_auto => true }
end

The problem will be that the ":address" entry is pointing to a server that you can't talk to. If the entry has the wrong value in it, fix it. Otherwise this is a system (or network) management problem, not a programming problem.

Send a string to wifi connected device return the EHOSTUNREACH (No route to host) in android

Make sure you turn off the firewalls on that port.

To make sure IP is up we usually ping that machine.

There is a tool called wireshark that taps the packets coming to your machine. So put you send function in while 1000 loop and pump messages. Turn wiresahrak at the server and see if you are able to get the packets there.

There are lots of other programs which can connects to sockets. take a sample java program and try to get connected to the other socket. If it does, your android stuff will also do.



Related Topics



Leave a reply



Submit