Errno :: EHOSTUNREACH无主机路线 - 连接(2)

Raj*_*aju 7 ruby

Errno::EHOSTUNREACH in UsersController#create

No route to host - connect(2)
Run Code Online (Sandbox Code Playgroud)

使用Rails应用程序发送邮件时出现此错误.

0x4*_*672 8

该错误Errno::EHOSTUNREACH: No route to host - connect(2)表示路由问题,可能与错误的IP地址有关.您可能在/etc/hosts(将主机名映射到IP地址的主机文件)或其他地方指定了错误的IP ,例如在config/deploy.rb等中.如果您使用具有DHCP服务器的本地网络,则IP地址可能会更改经常.


Mar*_*tuc 5

建立在joeshmo的答案上:

begin
  # problematic code
rescue Errno::EHOSTUNREACH
  # log the error
  # let the User know
rescue
  # handle other exceptions
end
Run Code Online (Sandbox Code Playgroud)