getaddrinfo: nodename nor servname provided, or not known

前端 未结 13 1627
梦谈多话
梦谈多话 2020-12-02 12:14

I have a Ruby on Rails application that I am deploying on a computer running Mac OS X 10.6. The code where the problem arises is run by a delayed_job. The problem only occur

13条回答
  •  青春惊慌失措
    2020-12-02 12:29

    rest-client's RestClient needs the http: scheme when resolving the URL. It calls Net::HTTP for you, which doesn't want the http: part, but rest-client takes care of that.

    Is the URL the actual one you are attempting to reach? example.org is a valid domain used for testing and documentation and is reachable; I'd expect the "api" and "api_endpoint" parts to fail and see that when I try to reach them.

    require 'socket'
    
    IPSocket.getaddress('example.org') # => "2620:0:2d0:200::10"
    IPSocket.getaddress('api.example.org') # => 
    # ~> -:7:in `getaddress': getaddrinfo: nodename nor servname provided, or not known (SocketError)
    # ~>    from -:7:in `
    '

    Here's what I get using Curl:

    greg-mbp-wireless:~ greg$ curl api.example.org/api_endpoint
    curl: (6) Couldn't resolve host 'api.example.org'
    greg-mbp-wireless:~ greg$ curl example.org/api_endpoint
    
    
    404 Not Found
    
    

    Not Found

    The requested URL /api_endpoint was not found on this server.


    Apache Server at example.org Port 80
    greg-mbp-wireless:~ greg$ curl example.org Example Web Page

    You have reached this web page by typing "example.com", "example.net","example.org" or "example.edu" into your web browser.

    These domain names are reserved for use in documentation and are not available for registration. See RFC 2606, Section 3.

提交回复
热议问题