# Re: Socket.getaddrinfo and IPSocket.getaddress super slow?

**URL:** <https://www.ruby-forum.com/t/re-socket-getaddrinfo-and-ipsocket-getaddress-super-slow/148450>\
**Category:** Ruby\
**Created:** [September 12, 2008, 11:42pm UTC](https://www.ruby-forum.com/t/re-socket-getaddrinfo-and-ipsocket-getaddress-super-slow/148450 "2008-09-12T23:42:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![stickstone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/6f9a4e/32.png) [@stickstone](https://www.ruby-forum.com/u/stickstone)\
**Post date:** [September 12, 2008, 11:42pm UTC](https://www.ruby-forum.com/t/re-socket-getaddrinfo-and-ipsocket-getaddress-super-slow/148450/1 "2008-09-12T23:42:58Z")

</div>

> Anyone know why Socket.getaddrinfo and IPSocket.getaddress take up to 3  
> seconds to return when the host doesn’t have a record in DNS?

They seem to do reverse DNS lookups on occasions where you might not  
want  
them to (e.g. finding the IP address to which a socket is bound). Try  
adding  
to the top of your program:

require ‘socket’  
Socket.do\_not\_reverse\_lookup=true

---

<div class="post-metadata">

**Author:** ![stickstone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/6f9a4e/32.png) [@stickstone](https://www.ruby-forum.com/u/stickstone)\
**Post date:** [September 13, 2008, 12:02am UTC](https://www.ruby-forum.com/t/re-socket-getaddrinfo-and-ipsocket-getaddress-super-slow/148450/2 "2008-09-13T00:02:00Z")

</div>

Brian C. wrote:

> > Anyone know why Socket.getaddrinfo and IPSocket.getaddress take up to 3  
> > seconds to return when the host doesn’t have a record in DNS?
> 
> They seem to do reverse DNS lookups on occasions where you might not  
> want  
> them to (e.g. finding the IP address to which a socket is bound). Try  
> adding  
> to the top of your program:
> 
> require ‘socket’  
> Socket.do\_not\_reverse\_lookup=true

The Zeroconf (avahi) mDNS service seems to pretty well bone things up on  
Ubuntu 7/8 as well. You might want to shut it off and see what happens  
(it seems to be running by default) you’re hanging out with zoo  
critters.
