# Weird Net::HTTP error

**URL:** <https://www.ruby-forum.com/t/weird-net-http-error/64388>\
**Category:** Ruby\
**Created:** [June 25, 2006, 7:20am UTC](https://www.ruby-forum.com/t/weird-net-http-error/64388 "2006-06-25T07:20:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![benjohnson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/3ec8ea/32.png) [@benjohnson](https://www.ruby-forum.com/u/benjohnson)\
**Post date:** [June 25, 2006, 7:20am UTC](https://www.ruby-forum.com/t/weird-net-http-error/64388/1 "2006-06-25T07:20:01Z")

</div>

You can copy and paste this in irb, but…this is a really strange  
problem. If ssh into my server in Oregon and paste the following code in  
irb it works just fine. If I ssh in one of my servers in Boston and  
paste the same code in irb I get a connection refused error. Any idea  
why this is happening?

Here is the code:

require ‘net/http’  
require ‘uri’

uri =  
URI.parse(‘[http://www.ticketmaster.com/event/0A003C8C9F3F6DF3?artistid=735836&majorcatid=10001&minorcatid=60](http://www.ticketmaster.com/event/0A003C8C9F3F6DF3?artistid=735836&majorcatid=10001&minorcatid=60)’)  
http = Net::HTTP::Proxy(nil).new(uri.host)  
req = Net::HTTP::Get.new(uri.path)  
req.add\_field ‘User-Agent’, ‘Mozilla/5.0 (X11; U; Linux i686; en-US;  
rv:1.8.0.3) Gecko/20060425 SUSE/1.5.0.3-7 Firefox/1.5.0.3’  
req.add\_field ‘Accept’,  
‘text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,_/_;q=0.5’  
req.add\_field ‘Accept-Language’, ‘en-us,en;q=0.5’  
req.add\_field ‘Accept-Charset’, ‘ISO-8859-1,utf-8;q=0.7,\*;q=0.7’  
req.add\_field ‘Keep-Alive’, ‘300’  
req.add\_field ‘Connection’, ‘keep-alive’  
res = http.start { |http| http.request req }

Also, the reason I added all of those headers is because ticket master  
checks for them. As far as I can tell, those headers are generic and I’m  
not sure why it would work on one server and not on another.

Any help is greatly appreciated.

---

<div class="post-metadata">

**Author:** ![benjohnson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/3ec8ea/32.png) [@benjohnson](https://www.ruby-forum.com/u/benjohnson)\
**Post date:** [June 25, 2006, 7:25am UTC](https://www.ruby-forum.com/t/weird-net-http-error/64388/2 "2006-06-25T07:25:56Z")

</div>

Also, if you add

puts res.body

You will get all of the HTML for that page. Just a note that might help.

Thanks a lot.

---

<div class="post-metadata">

**Author:** ![benjohnson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/3ec8ea/32.png) [@benjohnson](https://www.ruby-forum.com/u/benjohnson)\
**Post date:** [June 25, 2006, 7:51am UTC](https://www.ruby-forum.com/t/weird-net-http-error/64388/3 "2006-06-25T07:51:49Z")

</div>

Ben J. wrote:

> You can copy and paste this in irb, but…this is a really strange  
> problem. If ssh into my server in Oregon and paste the following code in  
> irb it works just fine. If I ssh in one of my servers in Boston and  
> paste the same code in irb I get a connection refused error. Any idea  
> why this is happening?

_Exact_ same OS and configuration on both machines? Exact same Ruby  
version? Firewalls? Routers? DNS stuff?

Can you shell in and connect from the CLI to the target Web site using  
lynx or wget?

–  
James B.

“Discover the recipes you are using and abandon them.”

- Brian Eno and Peter Schmidt, Oblique Strategies

---

<div class="post-metadata">

**Author:** ![benjohnson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/3ec8ea/32.png) [@benjohnson](https://www.ruby-forum.com/u/benjohnson)\
**Post date:** [June 25, 2006, 8:03am UTC](https://www.ruby-forum.com/t/weird-net-http-error/64388/4 "2006-06-25T08:03:54Z")

</div>

On Sun, 25 Jun 2006 14:51:19 +0900  
James B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 

Yeah, if anything it is an issue on your server as I can execute the  
code fine and I am in Boston.

---

<div class="post-metadata">

**Author:** ![benjohnson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/3ec8ea/32.png) [@benjohnson](https://www.ruby-forum.com/u/benjohnson)\
**Post date:** [June 25, 2006, 9:09am UTC](https://www.ruby-forum.com/t/weird-net-http-error/64388/5 "2006-06-25T09:09:07Z")

</div>

James B. wrote:

> Ben J. wrote:
> 
> > You can copy and paste this in irb, but…this is a really strange  
> > problem. If ssh into my server in Oregon and paste the following code in  
> > irb it works just fine. If I ssh in one of my servers in Boston and  
> > paste the same code in irb I get a connection refused error. Any idea  
> > why this is happening?
> 
> _Exact_ same OS and configuration on both machines? Exact same Ruby  
> version? Firewalls? Routers? DNS stuff?
> 
> Can you shell in and connect from the CLI to the target Web site using  
> lynx or wget?
> 
> –  
> James B.
> 
> “Discover the recipes you are using and abandon them.”
> 
> - Brian Eno and Peter Schmidt, Oblique Strategies

curl --url [www.ticketmaster.com](http://www.ticketmaster.com) doesn’t work either. So I guess the IP  
is banned from that data center, ha ha.

Thanks for your help. I guess its not a ruby issue.
