meshackofi meshackofi - 5 months ago 27x
Ruby Question

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

Where can i find configuration to the SMTP server?

**************/usr/lib/ruby/1.8/net/smtp.rb:551:in `initialize': No
route to host - connect(2) (Errno::EHOSTUNREACH)
/usr/lib/ruby/1.8/net/smtp.rb:551:in `open'
/usr/lib/ruby/1.8/net/smtp.rb:551:in `do_start'
/usr/lib/ruby/1.8/timeout.rb:67:in `timeout'
/usr/lib/ruby/1.8/timeout.rb:101:in `timeout'
/usr/lib/ruby/1.8/net/smtp.rb:551:in `do_start'
/usr/lib/ruby/1.8/net/smtp.rb:525:in `start'


You appear to be using the Ruby "Mail" library :

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 => "",
                           :port => 587,
                           :domain => '',
                           :user_name => '<username>', 
                           :password => '<password>',
                           :authentication => 'plain',
                           :enable_starttls_auto => true }

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.