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

Errno::EHOSTUNREACH in UsersController#create No route to host - connect(2) 

when sending mail with a Rails application, I get this error.

+6
source share
5 answers

The error Errno::EHOSTUNREACH: No route to host - connect(2) indicates a routing problem and, probably, something is connected with the wrong IP address. You may have specified the wrong IP address in /etc/hosts (the hosts file that matches hostnames with IP addresses) or in another place, for example, in config / deploy.rb, etc. If you use a local area network with a DHCP server, IP addresses can change frequently.

+7
source

Based on joeshmo's answer:

 begin # problematic code rescue Errno::EHOSTUNREACH # log the error # let the User know rescue # handle other exceptions end 
+5
source

This may not apply to you, but I had a similar problem. We had problems with our internal mail server, the web host cannot deliver emails to our own addresses. To get around this problem, which is out of my control, and avoid making 500 errors, I just caught the exception.

In the controller that sends emails, I wrapped up the mail program call:

  Notifier.deliver_issue_updated(@issue, @changes, current_user) 

Like this

  begin Notifier.deliver_issue_updated(@issue, @changes, current_user) rescue flash[:notice] += " Unable to deliver email notices." end 

Now the user is notified that the letter did not come out, but was not violated by the 500 error.

Hope this helps.

+1
source

If you are working on deploying chef-client, this will be the problem with the wrong HOST / SERVER IP in client.rb

 cd /etc/chef/ 

change client.rb

 chef_server_url "http://CORRECT_SERVER_IP:4000" 
+1
source

Ok, I have the same error. So I used one chef server, which is located on the Onpremise "Z" server and tried to load node "X". So I wrote a cookbook that records the host names and ipaddresses of all clients, which include the ip and hostname of server "Y" in /etc/hosts .

So what am I to blame.

I downloaded nodes in the cloud with the chef server, which is located on Onpremise. I changed the network interface "Y" and forgot that the client ip, which is them with "Z", is different from the real one. Later I tried to load "X" with "Y", but since X /etc/hosts contains the old ip Y, it could not find the route for the host, as it tried to use the old ip.

Then I tried changing the old IP address in /etc/hosts and running chef-client again, then everything went well. Hope this helps you.

Remember that you may encounter this error even when cname points to a different IP address and not to it.

Therefore, whenever you get this error, try ssh to the chef server from node, you want to run chef-client and see if you can connect. If this is not connected, then this is the same as I explained above

0
source

Source: https://habr.com/ru/post/888233/


All Articles