8

I currently have:

$ rails s
=> Booting WEBrick
=> Rails 3.0.9 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2011-11-30 13:18:00] INFO  WEBrick 1.3.1
[2011-11-30 13:18:00] INFO  ruby 1.9.2 (2011-02-18) [x86_64-darwin10.8.0]
[2011-11-30 13:18:00] INFO  WEBrick::HTTPServer#start: pid=4204 port=3000

The problem I'm having is I'm using openID for auth and getting the following error:

[2011-11-30 13:18:19] ERROR WEBrick::HTTPStatus::RequestURITooLarge

In the browser:

Request-URI Too Large
WEBrick::HTTPStatus::RequestURITooLarge
WEBrick/1.3.1 (Ruby/1.9.2/2011-02-18) at macbook-pro.local:3000

How can I fix this? Can I update WEBrick or do I really need to use a different web server?

Thanks

chrismdp
  • 58
  • 4
AnApprentice
  • 108,152
  • 195
  • 629
  • 1,012
  • I tried Unicorn but get: You have already activated rack 1.3.3, but your Gemfile requires rack 1.2.4. Consider using bundle exec. (Gem::LoadError) – AnApprentice Nov 30 '11 at 21:37
  • Need to add this is a localhost issue. I'm trying to get this bug fixed locally only at the moment – AnApprentice Dec 01 '11 at 02:15

3 Answers3

9

In Ruby 1.9.3. source, it says that MAX_URI_LENGTH = 2083. That means that the latest version of Webrick can't handle urls longer that this. And that's what the WEBrick::HTTPStatus::RequestURITooLarge exception is telling you.

The solution therefore is to use a different web server. One of the most favourite ones is Thin:

sudo gem install thin

cd to/your/rails/app

thin -h

thin -a localhost start
Marek Příhoda
  • 11,108
  • 3
  • 39
  • 53
  • When I try thing I get an error: /.rvm/gems/ruby-1.9.2-p180@andyw/gems/bundler-1.0.15/lib/bundler/runtime.rb:31:in `block in setup': You have already activated rack 1.3.3, but your Gemfile requires rack 1.2.4. Consider using bundle exec. (Gem::LoadError) – AnApprentice Dec 01 '11 at 01:56
  • ok figured that out. Does thing not show rails logging like webrick? – AnApprentice Dec 01 '11 at 02:06
  • Wait this is for local... Are you saying I should use thing for local? – AnApprentice Dec 01 '11 at 02:09
  • 1
    Actually, I would run it use `bundle exec rails s thin`. This will run the rails server using thin as the web server. – Batkins Jun 22 '12 at 14:16
  • If you are using `rvm` to install `thin`. Just use `gem install thin`. – Saurabh Jan 15 '15 at 10:00
6

Like said here, you could change the MAX_URI_LENGTH using this code:

WEBrick::HTTPRequest.const_set("MAX_URI_LENGTH", 10240)
Anthony O.
  • 22,041
  • 18
  • 107
  • 163
0

I see you've tried unicorn: have you tried running it through bundler? Add:

gem :unicorn

to your Gemfile and run:

bundle exec unicorn_rails

to start the server and browse to http://localhost:8080.

chrismdp
  • 58
  • 4