This is a very old thread but I think I've found what was wrong.
When you use net/http and try to instantiate a new object passing the URL string http = Net::HTTP.new("http://127.0.0.1:4567")
, you'll get this error.
you have to instantiate using an URI object, just like:
uri = URI.parse("http://localhost:4567")
http = Net::HTTP.new(uri.host, uri.port)