Desi Programmer @ Work

Slow Rails/WEBRick server inside VirtualBox

While trying to play around with Rails running in a VirtualBox and accessing it from my host Windows OS, I found it to be painfully slow. I'd heard that Rails is slow but surely not slow enough to respond to a simple request in over a minute.

The problem is that WEBRick, the default development server for Rails 3.x, can be problematic with remote requests. The problem is caused by Reverse Lookups by the web server which cause the server to respond only after the lokups fails by timing out,

This can be fixed by replacing the following line in WEBrick's config.rb:

:DoNotReverseLookup => nil,


:DoNotReverseLookup => true

With normal installations config.rb can be found in /usr/lib/ruby/<version>/webrick/config.rb, or if you are using rvm, it'll be in ~/rvm/rubies/ruby-<version>/lib/ruby/1.9.1/webrick/.

This now makes the requests served almost instantly rather than make you wait till death by frustration.