简体   繁体   English

Rails Heroku SocketError:getaddrinfo:名称或服务未知

[英]Rails Heroku SocketError: getaddrinfo: Name or service not known

I am on a heroku app, Ruby 2.2.0, Rails 4.0.12 and using the geokit-rails gem.我在使用 heroku 应用程序、Ruby 2.2.0、Rails 4.0.12 并使用 geokit-rails gem。

When I do a IpGeocoder.geocode(request.remote_ip) I get the error:当我做一个IpGeocoder.geocode(request.remote_ip)我得到错误:

Caught an error during Ip geocoding call: getaddrinfo: Name or service not known

I searched online and found that the solution is to make an initialiser and require a library:我在网上搜了一下,发现解决办法是做一个初始化器,需要一个库:

require 'resolv-replace'

When I do so I get the error:当我这样做时,我收到错误:

Caught an error during Ip geocoding call: Hostname not known: api.hostip.info

I am not sure what I should do then.我不知道我应该做什么。 On my development machine works fine.在我的开发机器上工作正常。 Any clue what the issue is?任何线索是什么问题?

Heroku uses forwarding, that causes request.remote_ip return internal heroku ip address, which cannot be processed by IpGeocoder for some reason. Heroku 使用转发,这导致request.remote_ip返回内部 heroku ip 地址,由于某种原因无法被 IpGeocoder 处理。

Try to use request.env['HTTP_X_FORWARDED_FOR'] insted.尝试使用request.env['HTTP_X_FORWARDED_FOR']

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法启动Rails服务器! “ getaddrinfo:名称或服务未知(SocketError)” - Can't start Rails server! “getaddrinfo: Name or service not known (SocketError)” Rails服务器错误“初始化”:getaddrinfo:名称或服务未知(SocketError) - rails server error `initialize': getaddrinfo: Name or service not known (SocketError) SSL 证书 getaddrinfo:名称或服务未知(SocketError)Rails-4.2.0 - SSL Certificate getaddrinfo: Name or service not known (SocketError) Rails-4.2.0 Rails 3机械化-SocketError:getaddrinfo:主机或名称未知 - Rails 3 Mechanize - SocketError: getaddrinfo: Host or name not known Elasticsearch SocketError(getaddrinfo:名称或服务未知) - Elasticsearch SocketError (getaddrinfo: Name or service not known) 「rescue500 => SocketError : getaddrinfo: Name or service not known」无法解析 - 「rescue500 => SocketError : getaddrinfo: Name or service not known」 cannot be resolved 在狂欢中面临问题 SocketError (getaddrinfo: Name or service not known) - Facing issue SocketError (getaddrinfo: Name or service not known) in spree aws-sdk gem:SocketError:getaddrinfo:名称或服务未知 - aws-sdk gem: SocketError: getaddrinfo: Name or service not known UsuariosController#forgot中的SocketError-getaddrinfo:名称或服务未知 - SocketError in UsuariosController#forgot - getaddrinfo: Name or service not known Rails POST:Heroku上的“ SocketError:getaddrinfo:名称解析中的临时失败”,但不在本地 - Rails POST: “SocketError: getaddrinfo: Temporary failure in name resolution” on heroku but not locally
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM