Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
EventMachine-aware pure Ruby DNS resolution
branch: master
Failed to load latest commit information.
lib Use Resolv::DNS::Config
test Add support for reverse DNS resolution: `EM::DnsResolver.reverse`.
.gitignore Initial commit to em-resolv-replace.
History.rdoc prepare for 1.1.3 release
LICENSE Modernize gem, remove jeweler, prep for 1.1.2 release
README.rdoc Typo
Rakefile Modernize gem, remove jeweler, prep for 1.1.2 release
VERSION prepare for 1.1.3 release
em-resolv-replace.gemspec prepare for 1.1.3 release



EventMachine-aware DNS lookup for Ruby.

Ruby's stock DNS resolution, by default, blocks the entire Ruby VM from processing while the lookup is happening, because it calls out to the native libc resolver code. A slow DNS server can cause your entire Ruby process to grind to a halt. Ruby comes with a pure Ruby replacement that is not loaded by default:

require 'resolv'
require 'resolv-replace'

'resolv' is the pure Ruby DNS resolver. 'resolv-replace' monkeypatches the various Ruby Socket objects to use resolv. This gem monkeypatches the monkeypatch so that the Socket classes will use an EventMachine-aware resolver, em-dns-resolver.


em-resolv-replace requires Ruby 1.9.


gem install em-resolv-replace


Just require em-resolv-replace when initializing your application:

require 'em-resolv-replace'

The code will use the EM-aware resolver if EventMachine is running.


em-dns-resolver.rb is taken from the em-dns project, with a connection bugfix applied by myself, and was written by Aman Gupta and Stephan Maka.


Mike Perham, @mperham, mperham AT,

Something went wrong with that request. Please try again.