As mentioned above, this seems to be a duplicate of another problem, although this issue specifically mentions webrick and Remote Desktop Connection, none of which I was looking for since I did not know that this was specific to webrick.
Therefore, I think it should be noted that this is NOT the wrong setting for the parameters of a virtual machine or BIOS, or something like that. This is strictly a problem with the case. Other services work very well if they are not trying to perform reverse DNS queries.
The problem is related to the default setting for Webrick to try to do a reverse DNS lookup, which has problems when the lookup fails, as it tends to work consistently for me on my local machine.
There are several ways to fix this.
Hack / etc / hosts
First, hack /etc/hosts so that your client machine has a record. Hacking /etc/hosts is semi-mobile, but basically it is figuring out what is the IP address of your host machine and adding a line to your /etc/hosts . This requires root privileges.
- Get your IP address - this will be visible in the Rails console when the request is made and will look something like this:
Started GET "/" for 10.0.2.2 at Tue Aug 21 11:33:23 -0700 2012 - in this case the IP address will be 10.0.2.2. - Add a line to
/etc/hosts to identify this IP address: 10.0.2.2 Nerdmaster
Everything should be fine!
Disable daemon
This seems to work for some ubuntu users:
service avahi-daemon stop
Given that you are killing the service, there may be other applications that have problems. This is probably best as a temporary measure, but not permanent, but I know little about the service, so donβt think about it :)
It also requires root privileges.
Hack webrick
I really despise the Ruby kernel hacker code, which I have to re-crack with every update, but this is what many people do:
- Find
webrick/config.rb- Could be in
/usr/lib/ruby/[version]/webrick/config.rb if you use regular Ruby - If you use RVM, you need to find the appropriate ruby ββdirectory, for example.
/home/username/.rvm/rubies/[version]/lib/ruby/[version]/webrick/config.rb - I don't know jack about other options like rbenv
- In the worst case, try
find / -type d -name "webrick"
- Edit in your favorite editor (obviously it will be vim)
- Find
:DoNotReverseLookup => nil . - Change
nil to true . - If you do not see this option, you may need to use
/etc/hosts hack above.
If you are not using rvm or something similar, this will require root permissions.
Do not use webrick
I don't think this is a real solution, as webrick is sometimes your best (or at least the fastest) option, but you can try a different server. Thin and mongrel seem to have good support and, based on what others say with this problem, do not seem to do a reverse DNS lookup. I have not tried these approaches, so I donβt know exactly how good they are.
This can be done without root permissions.