Gabriel Gabriel - 1 year ago 83
Ruby Question

Error When Making REST HTTP Request to 3rd Pary API. Possibly relate to IPv6

I am trying to make some http request to a third party API using rest-client or httparty. The code Im running is:

on terminal:

httparty ''

Its throwing this error:

/Users/user_name/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/net/http.rb:879:in `initialize': No route to host - connect(2) for "" port 80 (Errno::EHOSTUNREACH)
from /Users/user_name/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/net/http.rb:879:in `open'
from /Users/user_name/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/net/http.rb:879:in `block in connect'
from /Users/user_name/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/timeout.rb:73:in `timeout'
from /Users/user_name/.rvm/rubies/ruby-

in my app:


They are throwing a similar error:

Errno::EHOSTUNREACH: No route to host - connect(2) for "" port 80

from /Users/user_name/.rvm/gems/ruby-2.2.3/gems/http-0.9.9/lib/http/timeout/null.rb:18:in `initialize'

I think this has something to do with IP configurations, but Im not sure where to start troubleshooting.
I'd appreciate if someone can point me in the right direction on how to solve this.

Potentially Relevant Notes:
1) I've been getting this error since I updated from an older version of OSX to Sierra OSX. I did that because prior to that, my http requests (with rest-client, httparty or curl) were working but they were consistently taking 1 minute and 16 seconds for very little data. When I do curl now, they work pretty fast, so that problem was solved.

Answer Source

I solved this by shutting off IPv4. Not sure if that will come back to haunt me in the future, but for now that has eliminated all issues with all http request clients.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download