Problem with a simple open-uri request

I need to call third party API in my rails app. I decide to use open-uri
(but also tried the NET::HTTP.get and gives me the same error), and to
this:

open(“http://www.example.org”) do |f|
puts f.base_uri #=> http://www.example.org
puts f.status #=> [“200”, “OK”]
end

But it gives me:

getaddrinfo: Name or service not known

I can’t come up with a solution

Scott R. wrote in post #1169990:

On Mar 11, 2015, at 8:46 AM, Nicolò Benigni [email protected]
wrote:

getaddrinfo: Name or service not known

So it’s unable to resolve the host name. Either you’ve got the name
wrong, or there’s something in your OS config preventing it from being
resolved correctly.

It is exactly what I was thinking…
It doensn’t work with the http://www.example.org url neither, so I guess
that the problem it on the sys configuration.

Are you sure that there is nothing else that could cause the problem,
maybe rails configuration?

On Mar 11, 2015, at 8:46 AM, Nicolò Benigni [email protected]
wrote:

getaddrinfo: Name or service not known

So it’s unable to resolve the host name. Either you’ve got the name
wrong, or there’s something in your OS config preventing it from being
resolved correctly.

Stupid me! It was a permission problem on the resolv.conf file! thanks
anyway!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs