Getting "Incomplete response received from application" in Rails
Asked Answered
B

2

6

Can someone please help? My stack is ubuntu-server 14.04 with nginx/passenger and ruby 2.2.2. I can't manage to make my project work in production. Everything runs ok in development.

secrets.yml

production:
  secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
  secret_token: <%= ENV["SECRET_KEY_BASE"] %>

server

server { 
    listen 80; 
    server_name logvs.local; 
    passenger_enabled on; 
    passenger_app_env development;
    root /var/www/logvs/public; 
}

error.log

App 2532 stderr: [ 2015-06-07 22:56:01.4724 2610/0x000000014d6b00(Worker 1) utils.rb:85 ]: *** Exception RuntimeError in Rack application object (Missing `secret_token` and `secret_key_base` for 'production' environment, set these values in `config/secrets.yml`) (process 2610, thread 0x000000014d6b00(Worker 1)):
App 2532 stderr:    from /home/username/.rvm/gems/ruby-2.2.2/gems/railties-4.2.1/lib/rails/application.rb:534:in `validate_secret_key_config!'
App 2532 stderr:    from /home/username/.rvm/gems/ruby-2.2.2/gems/railties-4.2.1/lib/rails/application.rb:246:in `env_config'
App 2532 stderr:    from /home/username/.rvm/gems/ruby-2.2.2/gems/railties-4.2.1/lib/rails/engine.rb:514:in `call'
App 2532 stderr:    from /home/username/.rvm/gems/ruby-2.2.2/gems/railties-4.2.1/lib/rails/application.rb:164:in `call'
App 2532 stderr:    from /home/username/.rvm/gems/ruby-2.2.2/gems/passenger-5.0.9/lib/phusion_passenger/rack/thread_handler_extension.rb:94:in `process_request'
App 2532 stderr:    from /home/username/.rvm/gems/ruby-2.2.2/gems/passenger-5.0.9/lib/phusion_passenger/request_handler/thread_handler.rb:149:in `accept_and_process_next_request'
App 2532 stderr:    from /home/username/.rvm/gems/ruby-2.2.2/gems/passenger-5.0.9/lib/phusion_passenger/request_handler/thread_handler.rb:110:in `main_loop'
App 2532 stderr:    from /home/username/.rvm/gems/ruby-2.2.2/gems/passenger-5.0.9/lib/phusion_passenger/request_handler.rb:414:in `block (3 levels) in start_threads'
App 2532 stderr:    from /home/username/.rvm/gems/ruby-2.2.2/gems/passenger-5.0.9/lib/phusion_passenger/utils.rb:111:in `block in create_thread_and_abort_on_exception'
[ 2015-06-07 22:56:01.4731 2508/7f6775575700 age/Hel/Req/Utils.cpp:95 ]: [Client 1-1] Sending 502 response: application did not send a complete response

EDIT: I forgot to say I am using devise for authentication

Benzaldehyde answered 7/6, 2015 at 19:57 Comment(3)
Have you defined the missing environment variables? Until you do it will not run.Gonagle
Thanks to this line of code I could solve the problem in our server passenger_app_env development;Homage
Thank you, passenger_app_env solve my issue too.Contort
B
2

I had the similar problem. I ended up with manually entering env variables in the production in the .profile (or something similar) file in the production server.

app error: Missing `secret_token` and `secret_key_base` for 'production' environment

I've found good answer there How to solve error "Missing `secret_key_base` for 'production' environment" (Rails 4.1)

Baedeker answered 7/6, 2015 at 20:19 Comment(0)
J
0

I got really stuck with this problem because I had the problem before on my production server and I fixed it by setting my secret_key_base. However, now the problem started happening in my development environment. I'm using NGINX in my development environment but I still have MAMP installed separately and so the rails app was using the MySQL installed by MAMP, which appeared to be running. Somehow it had a bug, however, and I restarted MySQL and then it fixed the problem. So that's something to try: make sure MySQL (or whatever database you're using) is configured correctly, running, and if it is, try restarting it.

Jesselyn answered 2/8, 2016 at 5:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.