# I can't establish network connections with Ruby

**URL:** <https://rubytalk.org/t/i-cant-establish-network-connections-with-ruby/18417>\
**Category:** ruby-talk\
**Created:** [15 May 2005 15:25 UTC](https://rubytalk.org/t/i-cant-establish-network-connections-with-ruby/18417 "2005-05-15T15:25:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Meaneyedcat](https://avatars.discourse-cdn.com/v4/letter/m/48db29/32.png) [@Meaneyedcat](https://rubytalk.org/u/Meaneyedcat)\
**Post date:** [15 May 2005 15:25 UTC](https://rubytalk.org/t/i-cant-establish-network-connections-with-ruby/18417/1 "2005-05-15T15:25:30Z")

</div>

For some reason, I am unable to establish network connections anymore  
with Ruby code. For example, I execute the following code:

01 require 'net/http'  
02 Net::HTTP.start('[www.pragmaticprogrammer.com](http://www.pragmaticprogrammer.com)') do |http|  
03 response = http.get('/index.html')  
04 puts response.code  
05 end

And the application will simply hang. I don't believe it is a firewall  
issue because and I believe it is specific to (my install of) Ruby  
because:

1. I have shut down all my firewalls  
2. I can access the same web sites with my browser  
3. I setup a Tomcat servlet container on localhost, and the above code  
still hangs (even using 127.0.0.1, [192.168.1.XXX](http://192.168.1.XXX), localhost)  
4. When I try to run Ruby on Rails, the server won't accept a  
connections from my browser (Rails shows no errors and logs no  
messages, it too effectively hangs)  
5. When I try to do a /path/to/gem update, it hangs  
6. All other ruby apps seem to run fine if they do not access the net.

I have uninstalled Ruby and reinstalled it, but that didn't help. I am  
running on WindowsXP SP2. Does Ruby depend on any components of Windows  
that may have become corrupt?

Any help is GREATLY appreciated!  
Thanks!  
BCOT

---

<div class="post-metadata">

**Author:** ![Mike12](https://avatars.discourse-cdn.com/v4/letter/m/4491bb/32.png) [@Mike12](https://rubytalk.org/u/Mike12)\
**Post date:** [15 May 2005 16:16 UTC](https://rubytalk.org/t/i-cant-establish-network-connections-with-ruby/18417/2 "2005-05-15T16:16:16Z")

</div>

> For some reason, I am unable to establish network connections  
> anymore with Ruby code. For example, I execute the following code:
> 
> 01 require 'net/http'  
> 02 Net::HTTP.start('www.pragmaticprogrammer.com') do |http|  
> 03 response = http.get('/index.html')  
> 04 puts response.code  
> 05 end
> 
> And the application will simply hang. I don't believe it is a  
> firewall issue because and I believe it is specific to (my  
> install of) Ruby  
> because:

\<snip\>

> I have uninstalled Ruby and reinstalled it, but that didn't  
> help. I am running on WindowsXP SP2. Does Ruby depend on any  
> components of Windows that may have become corrupt?

I tried your code and it worked just fine for me - so there's no problems  
there.

If you reinstalled Ruby, then that tends to rule out the possibility of the  
Net library being FUBAR'ed.

Can you

telnet [www.pragmaticprogrammer.com](http://www.pragmaticprogrammer.com) 80

And then type GET when you reach a connected blinking cursor? Do you connect  
and see a returned bunch of HTML? If that fails, then it's your machine. If  
not, then we know that you can at least get outgoing connections from your  
machine. Also, you can try typing:

netsh firewall show state

To see what the exact state of the XP firewall is for certain. It should say  
"Operational mode = Disabled".

Do you have any additional firewalls -installed- on the computer (even if  
they're disabled)? I've seen many cases where ZoneAlarm does some crazy  
stuff to your machine (even when it's disabled and removed).

Hope some of that helps.

-M

---

<div class="post-metadata">

**Author:** ![Aaron\_Rustad](https://avatars.discourse-cdn.com/v4/letter/a/ac8455/32.png) [@Aaron\_Rustad](https://rubytalk.org/u/Aaron_Rustad)\
**Post date:** [15 May 2005 18:45 UTC](https://rubytalk.org/t/i-cant-establish-network-connections-with-ruby/18417/3 "2005-05-15T18:45:30Z")

</div>

Hi Mike, thanks for the help. I had ZoneAlarm shutdown, and it still  
didn't work. I uninstalled it and everything seems to work for me now.

thanks!  
BCOT.
