Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm trying to run a relatively simple rails app (http:// www.enkiblog.com/) and it kinda works. The comments and the admin interface only work when I use "script/ server -e production" and connect to Port 3000 (still in production mode though).

Nginx will have this in his error.log:

2009/06/02 21:46:10 [error] 11536#0: *18 upstream prematurely closed
connection while reading response header from upstream, client:
85.180.23.43, server: *.marc-seeger.de, request: "GET /admin HTTP/
1.1", upstream: "unix:/tmp/passenger.11520/master/
helper_server.sock:", host: "www.marc-seeger.de"
*** Exception NoMethodError in application (undefined method `each'
for nil:NilClass) (process 14080):
        from /opt/ruby-enterprise-1.8.6-20090421/lib/ruby/gems/1.8/
gems/passenger-2.2.2/lib/phusion_passenger/rack/request_handler.rb:
85:in `process_request'
        from /opt/ruby-enterprise-1.8.6-20090421/lib/ruby/gems/1.8/
gems/passenger-2.2.2/lib/phusion_passenger/abstract_request_handler.rb:
203:in `main_loop'
        from /opt/ruby-enterprise-1.8.6-20090421/lib/ruby/gems/1.8/
gems/passenger-2.2.2/lib/phusion_passenger/railz/
application_spawner.rb:340:in `start_request_handler'
        from /opt/ruby-enterprise-1.8.6-20090421/lib/ruby/gems/1.8/
gems/passenger-2.2.2/lib/phusion_passenger/railz/
application_spawner.rb:298:in `handle_spawn_application'
        from /opt/ruby-enterprise-1.8.6-20090421/lib/ruby/gems/1.8/
gems/passenger-2.2.2/lib/phusion_passenger/utils.rb:181:in `safe_fork'
        from /opt/ruby-enterprise-1.8.6-20090421/lib/ruby/gems/1.8/
gems/passenger-2.2.2/lib/phusion_passenger/railz/
application_spawner.rb:296:in `handle_spawn_application'
        from /opt/ruby-enterprise-1.8.6-20090421/lib/ruby/gems/1.8/
gems/passenger-2.2.2/lib/phusion_passenger/abstract_server.rb:337:in
`__send__'
        from /opt/ruby-enterprise-1.8.6-20090421/lib/ruby/gems/1.8/
gems/passenger-2.2.2/lib/phusion_passenger/abstract_server.rb:337:in
`main_loop'
        from /opt/ruby-enterprise-1.8.6-20090421/lib/ruby/gems/1.8/
gems/passenger-2.2.2/lib/phusion_passenger/abstract_server.rb:187:in
`start_synchronously'
        from /opt/ruby-enterprise-1.8.6-20090421/lib/ruby/gems/1.8/
gems/passenger-2.2.2/lib/phusion_passenger/abstract_server.rb:154:in
`start'
        from /opt/ruby-enterprise-1.8.6-20090421/lib/ruby/gems/1.8/
gems/passenger-2.2.2/lib/phusion_passenger/railz/
application_spawner.rb:192:in `start'
        from /opt/ruby-enterprise-1.8.6-20090421/lib/ruby/gems/1.8/
gems/passenger-2.2.2/lib/phusion_passenger/spawn_manager.rb:257:in
`spawn_rails_application'
        from /opt/ruby-enterprise-1.8.6-20090421/lib/ruby/gems/1.8/
gems/passenger-2.2.2/lib/phusion_passenger/
abstract_server_collection.rb:126:in `lookup_or_add'
        from /opt/ruby-enterprise-1.8.6-20090421/lib/ruby/gems/1.8/
gems/passenger-2.2.2/lib/phusion_passenger/spawn_manager.rb:251:in
`spawn_rails_application'
        from /opt/ruby-enterprise-1.8.6-20090421/lib/ruby/gems/1.8/
gems/passenger-2.2.2/lib/phusion_passenger/
abstract_server_collection.rb:80:in `synchronize'
        from /opt/ruby-enterprise-1.8.6-20090421/lib/ruby/gems/1.8/
gems/passenger-2.2.2/lib/phusion_passenger/
abstract_server_collection.rb:79:in `synchronize'
        from /opt/ruby-enterprise-1.8.6-20090421/lib/ruby/gems/1.8/
gems/passenger-2.2.2/lib/phusion_passenger/spawn_manager.rb:250:in
`spawn_rails_application'
        from /opt/ruby-enterprise-1.8.6-20090421/lib/ruby/gems/1.8/
gems/passenger-2.2.2/lib/phusion_passenger/spawn_manager.rb:153:in
`spawn_application'
        from /opt/ruby-enterprise-1.8.6-20090421/lib/ruby/gems/1.8/
gems/passenger-2.2.2/lib/phusion_passenger/spawn_manager.rb:282:in
`handle_spawn_application'
        from /opt/ruby-enterprise-1.8.6-20090421/lib/ruby/gems/1.8/
gems/passenger-2.2.2/lib/phusion_passenger/abstract_server.rb:337:in
`__send__'
        from /opt/ruby-enterprise-1.8.6-20090421/lib/ruby/gems/1.8/
gems/passenger-2.2.2/lib/phusion_passenger/abstract_server.rb:337:in
`main_loop'
        from /opt/ruby-enterprise-1.8.6-20090421/lib/ruby/gems/1.8/
gems/passenger-2.2.2/lib/phusion_passenger/abstract_server.rb:187:in
`start_synchronously'
        from /opt/ruby-enterprise-1.8.6-20090421/lib/ruby/gems/1.8/
gems/passenger-2.2.2/bin/passenger-spawn-server:61
Error during failsafe response: closed stream

Any idea?

p.s. debian 5.0

share|improve this question
    
I'm having this same issue although not using SQLite - the problem only started when I upgraded to Rails 3.1. Any suggestions as to why> –  bodacious Jun 29 '11 at 18:21
    
asset pipeline is my first suspect –  bodacious Jun 29 '11 at 18:21
    
For me it was the SQLite permissions –  rb2k Jul 2 '11 at 12:09
    
seems there's a bug with the latest Rails 3.1 release candidate. Enabling threadsafe mode solves this in the short-term but it's a rack issue –  bodacious Jul 3 '11 at 19:56

2 Answers 2

You can get a 502 error like this from nginx when you don't have the proper permissions set on an SQLite database.

share|improve this answer
    
As I mentioned in my answer, that actually was the solution :) It seems to have something to do with the permissions passenger uses to spawn the interpreter threads. I tried basically anything but I couldn't chmod my way out of this –  rb2k Jun 23 '09 at 17:22
up vote 0 down vote accepted

Turns out it was a passenger + sqlite + nginx + unix permissions problem.
I "solved" it by migrating to MySQL

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.