SocketError: getaddrinfo: nodename nor servname provided, or

Discussion in 'Ruby' started by Baq Haidri, May 6, 2008.

  1. Baq Haidri

    Baq Haidri Guest

    I'm trying to use Net/Http and am getting the following error:

    SocketError: getaddrinfo: nodename nor servname provided, or not known

    I'm on Mac OS X, Leopard, check out my ruby version/gem env below.

    Also, I double checked my etc/hosts and I do see an entry for
    localhost/127.0.0.1 there. Seems like this is a Leopard issue?

    [baq@baq:~]$ ruby -v
    ruby 1.8.6 (2007-09-24 patchlevel 111) [universal-darwin9.0]

    [baq@baq:~]$ gem environment
    RubyGems Environment:
    - RUBYGEMS VERSION: 1.0.1 (1.0.1)
    - RUBY VERSION: 1.8.6 (2007-09-24 patchlevel 111)
    [universal-darwin9.0]
    - INSTALLATION DIRECTORY: /Library/Ruby/Gems/1.8
    - RUBYGEMS PREFIX:
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby
    - RUBY EXECUTABLE:
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
    - RUBYGEMS PLATFORMS:
    - ruby
    - universal-darwin-9
    - GEM PATHS:
    -
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
    - /Library/Ruby/Gems/1.8
    - GEM CONFIGURATION:
    - :update_sources => true
    - :verbose => true
    - :benchmark => false
    - :backtrace => false
    - :bulk_threshold => 1000
    - REMOTE SOURCES:
    - http://gems.rubyforge.org
    --
    Posted via http://www.ruby-forum.com/.
    Baq Haidri, May 6, 2008
    #1
    1. Advertising

  2. Re: SocketError: getaddrinfo: nodename nor servname provided

    Can we pleas see the code that is causing this error?
    --
    Posted via http://www.ruby-forum.com/.
    Michael Boutros, May 7, 2008
    #2
    1. Advertising

  3. Baq Haidri

    Baq Haidri Guest

    Re: SocketError: getaddrinfo: nodename nor servname provided

    Here's the code:

    require 'net/http'
    Net::HTTP.start('http://www.google.com') do |http|
    response = http.get('/')
    puts response
    end







    --
    Posted via http://www.ruby-forum.com/.
    Baq Haidri, May 7, 2008
    #3
  4. Re: SocketError: getaddrinfo: nodename nor servname provided

    Try this:

    require 'net/http'
    Net::HTTP.start('www.google.com') do |http|
    response = http.get('/')
    puts response
    end


    #start doesn't take the protocol.
    --
    Posted via http://www.ruby-forum.com/.
    Michael Boutros, May 7, 2008
    #4
  5. Baq Haidri

    Baq Haidri Guest

    Re: SocketError: getaddrinfo: nodename nor servname provided

    Great, that did it!

    Thanks Michael! (and I apologize to everyone who was spammed with this
    message--I *did* do a google search & doc search but couldn't find a
    solution...)

    Michael Boutros wrote:
    > Try this:
    >
    > require 'net/http'
    > Net::HTTP.start('www.google.com') do |http|
    > response = http.get('/')
    > puts response
    > end
    >
    >
    > #start doesn't take the protocol.


    --
    Posted via http://www.ruby-forum.com/.
    Baq Haidri, May 7, 2008
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Laszlo Nagy
    Replies:
    0
    Views:
    454
    Laszlo Nagy
    Jul 25, 2006
  2. Laszlo Nagy
    Replies:
    2
    Views:
    588
    Laszlo Nagy
    Jul 31, 2006
  3. Ed
    Replies:
    6
    Views:
    1,255
    =?ISO-8859-1?Q?Arne_Vajh=F8j?=
    Aug 2, 2007
  4. Bradley, Todd
    Replies:
    0
    Views:
    308
    Bradley, Todd
    Nov 16, 2004
  5. Doug Livesey
    Replies:
    0
    Views:
    123
    Doug Livesey
    Apr 7, 2010
Loading...

Share This Page