[英]Rails/Sendgrid Error: getaddrinfo: name or service not known
I've all of a sudden started getting this error when creating users in my app. 在我的应用中创建用户时,我突然开始收到此错误。 Emails were working before I left for vacation, now I come back and this is what my tech support gives me!
在我去度假之前,电子邮件一直在工作,现在我回来了,这就是我的技术支持所提供的! Ugh.
啊。
So, I make a user, and I get redirected to my admin panel with the following error in a flash notice: getaddrinfo: name or service not known
. 因此,我创建了一个用户,并立即将其重定向到管理面板,并在通知中出现以下错误:
getaddrinfo: name or service not known
。 The user isn't created. 未创建用户。
Looking at the logs, it looks like everything worked fine: 查看日志,看起来一切正常:
I, [2016-04-12T08:01:52.089647 #11555] INFO -- : Started POST "/admin/user/new" for 72.238.202.193 at 2016-04-12 08:01:52 -0500
I, [2016-04-12T08:01:52.092114 #11555] INFO -- : Processing by RailsAdmin::MainController#new as HTML
I, [2016-04-12T08:01:52.092259 #11555] INFO -- : Parameters: {"utf8"=>"✓", "authenticity_token"=>"vxhuTwXhQo6nYrskQcYH9W56Ej95LgzEbs8cnkjXQI4=", "user"=>{"company_id"=>"35", "username"=>"myuser@thedomain.com", "first_name"=>"Test", "last_name"=>"User", "full_name"=>"Test User", "time_zone"=>"Central Time (US & Canada)", "email"=>"myuser@thedomain.com", "phone_number"=>"", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]", "reset_password_sent_at"=>"[FILTERED]", "remember_created_at"=>"", "sign_in_count"=>"0", "current_sign_in_at"=>"", "last_sign_in_at"=>"", "current_sign_in_ip"=>"", "last_sign_in_ip"=>"", "authentication_token"=>"", "enable_notifications"=>"1", "confirmation_token"=>"MBrmpsD6Wtf1VBrhtDyc", "confirmed_at"=>"", "confirmation_sent_at"=>"April 12, 2016 10:00", "unconfirmed_email"=>"myuser@thedomain.com", "terms_accepted"=>"1", "cancel_subscription"=>"0", "on_trial"=>"0", "is_account_owner"=>"1", "role_ids"=>["", "", "2"]}, "return_to"=>"https://www.myserver.com/admin/user?sort=created_at&sort_reverse=false", "_save"=>"", "model_name"=>"user"}
I, [2016-04-12T08:01:52.212064 #11555] INFO -- : Rendered devise/mailer/confirmation_instructions.html.erb (1.6ms)
I, [2016-04-12T08:01:52.340343 #11555] INFO -- :
Sent mail to myuser@thedomain.com (9.3ms)
I've filtered the email address but, rest assured, it's a valid email. 我已经过滤了电子邮件地址,但是请放心,这是一封有效的电子邮件。
I'm using EC2 to host my application, so I can't edit /etc/resolv.conf
since any changes will be overridden. 我正在使用EC2托管应用程序,因此无法编辑
/etc/resolv.conf
因为任何更改都将被覆盖。
I've run nslookup
to make sure the server can find the domain MX records, which it does using the nameserver specified in /etc/resolv.conf
. 我已经运行
nslookup
,以确保服务器可以找到域MX记录,使用/etc/resolv.conf
指定的名称服务器即可。
What else can I do to troubleshoot this issue? 我还可以做些什么来解决此问题?
I used a recommendation I ran across on another blog to use Ruby's version of Resolv
instead of the libc library with Ubuntu. 我使用了我在另一个博客上遇到的建议,即使用Ruby的
Resolv
版本而不是Ubuntu的libc库。 So, I added the following line to an initializer: require resolv-replace.rb
. 因此,我
require resolv-replace.rb
下行添加到了初始化程序: require resolv-replace.rb
。
Now my error is a little more descriptive: Hostname not known: smtp.sendgrid.net
, so I checked config/environments/production.rb
and it turns out I had a trailing space at the end of my host line. 现在,我的错误更具描述性:
Hostname not known: smtp.sendgrid.net
,所以我检查了config/environments/production.rb
,结果发现主机行末尾有空格。 Removed it and all is working now! 删除它,现在一切正常!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.