exceptionz

Thoughts on Technology, Methodology and Programming.

ActionMailer – SocketError (getaddrinfo: Name or service not known) blues

Posted by Marcus Wyatt on 23 December 2007

I launched a new website a week ago and had issues with the action mailer setup used by restful_authentication. For some reason I was receiving the socket error and google wasn’t to helpful either.

So what was the problem?

Well, first I thought it was my setup of Postfix. But it turned out to be my settings for my action mailer. Anyways, the address should not point to your complete domain name, but rather to localhost. Here is the code snippet:

ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:address => "localhost", # instead of "smtp.yourdomain.com",
:port => 25,
:domain => "yourdomain.com",
:authentication => :login,
:user_name => "user_name",
:password => "password"
}

Of course the ActionMailer settings should go into your environment.rb file (pre 2.0)

It is just very annoying that none of the docs or tutorials point this out….

Advertisements

10 Responses to “ActionMailer – SocketError (getaddrinfo: Name or service not known) blues”

  1. John said

    Wow… thanks man… I’ve been struggling with this problem all day. What a pain…

  2. Darren said

    Haha I was about to take my macbook pro and smash it over ruby and rails heads, till I found you… so thanks for saving myself a few thousand dollars.

  3. Marty McGee said

    Ooo, lifesaver! Thanks for writing this down. For awhile I thought I was having issues of a completely different matter (with Apache2.2.4 throwing Bad Sector errors), but that wasn’t the case at all. Once I fixed my :smtp settings as you’ve suggested, I was able to get passed the puzzling errors. Thanks!

  4. Billee D. said

    Good catch, Marcus! Thank you for posting this. I had been working on yet another CMS when I noticed that the contact form was not working. As you stated, Google was not my friend. So I let it languish while I finished-up other areas of the site.

    So today I had to revisit the contact form issues when I came across this post. I Changed my environments/production.rb ActionMailer settings as indicated, I added my changes to the Subversion repo for this project, I shelled (SSH) into my server, performed an “svn update” on the site, did a touch on the tmp/restart.txt and viola! Everything is working fine.

    It’s weird how little settings like this make Ruby just stop working. Add to that the simple fact that as you have indicated, and as far as I know, these settings are incorrectly documented or non-existent and you end up spending hours tracking down something as simple as a config setting. Weird…

    Thanks so much!

  5. jts said

    hi there,
    I’m continuing to get this message, despite setting server to localhost. I wonder if others are experiencing this and if they’ve found resolution to it..

  6. Scott said

    Thanks, this helped me get by an error I had when trying to set up redmine. Changing the host to localhost did the trick!

  7. lavanya said

    connection timed out; no servers could be reached

  8. Alex said

    This helped me fix my original error which this post is trying to fix, so thank you for that. But now I started getting a “connection refused” error 🙂

    I am not sure which error is worse and with which I am further from the solution 🙂 Any ideas?

  9. aditya said

    Thanks a zillion buddy!!!!! Rock n roll!!!!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: