Search code examples
ruby-on-railsthinwebrick

thin slow in development when not using localhost


I switched to using thin in local development instead of webrick.

When I access localhost:3000 it returns the page almost instantly just like webrick

But when I access myapp.local:3000 the browser spins for 20 seconds or so on each request before rendering the page. I'm not sure what it's doing during that time - the rails log shows the page being generated almost instantly - it almost seems like the browser is doing name resolution during that time or something else.

In my /etc/hosts i have

127.0.0.1 myapp.local

In webrick there was no difference between accessing myapp.local:3000 and localhost:3000.

But in thin there is the large difference mentioned above. Any theories? Much appreciated!


Solution

  • Look for the file /usr/lib/ruby/VERSION_OF_RUBY/webrick/config.rb and edit it. Replace/insert the following line as a new key of the General hash.

    :DoNotReverseLookup => true

    Restart webrick.

    Otherwise try running sudo service avahi-daemon stop

    See Webrick is very slow to respond. How to speed it up? for more details