连接被拒绝 - 连接(2)for" freegeoip.net" 80号港口

时间:2014-06-12 20:57:54

标签: ruby-on-rails geocoding

环境

  • Rails 4.0.4
  • Ruby 2.0.1
  • Geocoder gem

问题

今天我的应用程序已关闭,我无法在日志中解决问题:

Errno::ECONNREFUSED (Connection refused - connect(2) for "freegeoip.net" port 80):

看起来它与Geocoder宝石相关

如果在开发环境中没有发生这个问题,那就太奇怪了。

我检查了freegeoip并且看起来已经失效,这说我不知道​​为什么它会阻止我的应用程序运行

$ curl http://freegeoip.net 
curl: (7) couldn't connect to host

1 个答案:

答案 0 :(得分:3)

我是如何解决的

begin
  @location =  "#{request.location.city} #{request.location.country_code}"
rescue => e
  # handle the error here
  logger.debug "http://freegeoip.net must be down!"
  logger.debug e.message
end
相关问题