I am using the shoes's GUI builder and I get the below error when I make a simple HTTP request to my local Rails server
So when I make the request
res = Net::HTTP.get(URI.parse("http://sub.localhost:3000"))
I get the error:
Hostname not known: sub.localhost
/Applications/Shoes.app/Contents/MacOS/lib/ruby/2.2.0/resolv-replace.rb:12:in `rescue in getaddress'
/Applications/Shoes.app/Contents/MacOS/lib/ruby/2.2.0/resolv-replace.rb:9:in `getaddress'
/Applications/Shoes.app/Contents/MacOS/lib/ruby/2.2.0/resolv-replace.rb:23:in `initialize'
/Applications/Shoes.app/Contents/MacOS/lib/ruby/2.2.0/net/http.rb:879:in `open'
/Applications/Shoes.app/Contents/MacOS/lib/ruby/2.2.0/net/http.rb:879:in `block in connect'
/Applications/Shoes.app/Contents/MacOS/lib/ruby/2.2.0/timeout.rb:73:in `timeout'
/Applications/Shoes.app/Contents/MacOS/lib/ruby/2.2.0/net/http.rb:878:in `connect'
/Applications/Shoes.app/Contents/MacOS/lib/ruby/2.2.0/net/http.rb:863:in `do_start'
/Applications/Shoes.app/Contents/MacOS/lib/ruby/2.2.0/net/http.rb:852:in `start'
/Applications/Shoes.app/Contents/MacOS/lib/ruby/2.2.0/net/http.rb:1375:in `request'
shoes.rb:24:in `request'
shoes.rb:63:in `block (3 levels) in <main>'
-e:1:in `call'
/Applications/Shoes.app/Contents/MacOS/lib/ruby/2.2.0/resolv-replace.rb:12:in `rescue in getaddress'
/Applications/Shoes.app/Contents/MacOS/lib/ruby/2.2.0/resolv-replace.rb:9:in `getaddress'
/Applications/Shoes.app/Contents/MacOS/lib/ruby/2.2.0/resolv-replace.rb:23:in `initialize'
/Applications/Shoes.app/Contents/MacOS/lib/ruby/2.2.0/net/http.rb:879:in `open'
/Applications/Shoes.app/Contents/MacOS/lib/ruby/2.2.0/net/http.rb:879:in `block in connect'
/Applications/Shoes.app/Contents/MacOS/lib/ruby/2.2.0/timeout.rb:73:in `timeout'
/Applications/Shoes.app/Contents/MacOS/lib/ruby/2.2.0/net/http.rb:878:in `connect'
/Applications/Shoes.app/Contents/MacOS/lib/ruby/2.2.0/net/http.rb:863:in `do_start'
/Applications/Shoes.app/Contents/MacOS/lib/ruby/2.2.0/net/http.rb:852:in `start'
/Applications/Shoes.app/Contents/MacOS/lib/ruby/2.2.0/net/http.rb:1375:in `request'
shoes.rb:24:in `request'
shoes.rb:63:in `block (3 levels) in <main>'
-e:1:in `call'
My hosts file has 127.0.0.1 sub.localhost
and I can reach the address and make requests against it no problem, just not in the shoes project.
I followed this question's advice and bound my local ip address ex 123.12.12.1
, but get the same error Hostname not known: sub.123.12.12.1
This said to remove the line resolv-replace.rb:9:in
in the shoes project, but I get the same error Hostname not known: sub.123.12.12.1
I'm on a Mac
Use a custom DNS resolver to ensure that Ruby looks at the
hosts
file:Now
Net::HTTP
will use your custom resolver that checkshosts
first and successfully resolve your custom domains.