title: ruby `rescue in block in connect': Failed to open TCP connection to api
body: <p>I am fairly new to ruby and I am having issues using code that I found on this 
  <a href="https://github.com/jsgoecke/whitepages" rel="nofollow noreferrer">github</a>. It is meant to use the Whitepages API to use their service and I am using it to do a reverse phone lookup. Here is my whitepages.rb file:</p>
  
  <pre><code>require 'json'
  require 'net/https'
  require 'uri'
  
  
  class Whitepages
  
  #Initialize the Whitepages class
  # * api_key - The API key obtained from the Whitpages Developer website
  def initialize(api_key)
    api_version = "1.0"
  
    @api_key = api_key
    @base_uri = "http://api.whitepages.com/"
    @find_person_uri = @base_uri + "find_person/" + api_version + "/?"
    @reverse_phone_uri = @base_uri + "reverse_phone/" + api_version + "/?"
    @reverse_address_uri = @base_uri + "reverse_address/" + api_version + "/?"
  
    @uri = URI.parse(@base_uri)
    @http = Net::HTTP.new(@uri.host, @uri.port)
  end
  
  #Retrieves contact information about a telephone number
  #Accepts a hash:
  # * phone - May be 7 digits if state provided otherwise 10 (*REQUIRED*)
  # * state - Two digit code for the state
  #More details may be found here: http://developer.whitepages.com/docs/Methods/reverse_phone
  def reverse_phone(options)  
    resp, data = @http.get(build_uri(options, "reverse_phone"))
  
    if resp.code== 200
      return JSON.parse(data)
    else
      raise Exception,"code",resp.code
    end
  
  end
  
  
  
  #Build the appropriate URL
  def build_uri(options, type)
    case type
    when "reverse_phone"
      built_uri = @reverse_phone_uri
    when "reverse_address"
      built_uri = @reverse_address_uri
    when "find_person"
      built_uri = @find_person_uri
    end
  
    options.each do |key,value|
      if value != nil
        built_uri = built_uri + key + "=" + value.gsub(' ', '%20') + ";"
      end
    end
  
    built_uri = built_uri + "api_key=" + @api_key + ";outputtype=JSON"
    return built_uri
  end
  
  end
  </code></pre>
  
  <p>And here is the class I use to test the code:</p>
  
  <pre><code>require 'rubygems'
  require './whitepages'
  
  API_KEY = MY ACTUAL API KEY AS A STRING
  
  wp = Whitepages.new(API_KEY)
  
  
  
  data = wp.reverse_phone({ "phone"   =&gt; "4155551212", 
                        "state"   =&gt; "CA" })
  </code></pre>
  
  <p>When I run this file, I get the error: <code>rescue in block in connect': Failed to open TCP connection to api.whitepages.com:80 (getaddrinfo: Name or service not known) (SocketError)</code></p>
  
  <p>I can't find anything online specifically about connecting to APIs that would help me. Please, any help is greatly appreciated. PS: If you need to test the code, it does not take long at all to get a free API key from whitepages.com</p>