"Incomplete response received from application" from nginx / passenger

Ruby on-RailsNginxPassenger

Ruby on-Rails Problem Overview

I tried to deploy my rails app on nginx and ubuntu via capistrano like the tutorial on the page https://gorails.com/deploy/ubuntu/14.04. but at the end i get an error message:

Incomplete response received from application

in my browser. this is probably an error from passenger, but how can i figure out what to do?

Ruby on-Rails Solutions

Solution 1 - Ruby on-Rails

Your rails_env production don't have required set up,probably missing secret_key_base.

Open /etc/nginx/sites-available/default and change the rails_env to development:

rails_env production;
rails_env development;

If the app is loading it's not a passenger issue.

Production Solution:

  1. Enter your app root
  2. run: rake secret
  3. copy the output
  4. go to /yourapp/config/secrets.yml
  5. set the production secret_key_base

Restart the passenger app :

touch /yourapp/tmp/restart.txt

Solution 2 - Ruby on-Rails

This error occurs because you didn't set the secret_key_base. Follow these steps to fix it:

Go to your rails app directory

cd /path/rails-app

Generate secret key base

rake secret RAILS_ENV=production

Set environment variable


Restart the Rails app

touch /path/rails-app/tmp/restart.txt

Solution 3 - Ruby on-Rails

I had this problem over the weekend (it turned out there was an incompatibility between my versions of passenger and ruby).

However, nobody seems to be mentioning: the actual error might appear in /var/log/apache2/errors.log, not in any custom log.

Once you know that, hopefully your search will be easier!

Update, since I needed to refer back to this again - this hold true for nginx too - /var/log/nginx/error.log is your friend in that case!

Solution 4 - Ruby on-Rails

For those using Passenger:

• Navigate to root of your project.

• run bundle exec rake secret RAILS_ENV=production

• Copy the output and then run sudo nano config/secrets.yml

• Under production, replace the value of the secret_key_base with the recently copied rake secret.

• press CNTRL+X, then press y, then hit enter.

• run passenger-config restart-app and select the app you wish to restart.


Solution 5 - Ruby on-Rails

In my case, it was because my server was running out of RAM intermittently (during PDF generation). Once the PDF was generated, some RAM was restored and the error would disappear.

I had an ubuntu server with 500M of RAM.

I added some swap space and this error disappeared.

Solution 6 - Ruby on-Rails

Might be my answer is off topic, but when my database mysql server isn't running, i got this error too. Just in case someone has the same error.

so start/restart your database might be another answer.

Solution 7 - Ruby on-Rails

This means that your rails app tanked before actually getting to rails itself. This could be an exception in middleware, missing ENV key, something at the OS level.

Try booting the app locally first and doing what you did to get the error in production. If everything is fine, check all of your logs. Check nginx logs, your passenger logs, and finally any other OS specific logs pertaining to booting and running your app.

Solution 8 - Ruby on-Rails

Is there anybody like me who got this error after uploading a file?

My solution is check the name of the file which may has some special characters like `[(~.

Just remove it then upload the file again.

Good luck~

Solution 9 - Ruby on-Rails

I got this, only on my test server and not in production, because I was requesting a URL that didn't exist, and I guess in the test environment, Rails throws an error instead of returning a 404 response.


All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionjuicyView Question on Stackoverflow
Solution 1 - Ruby on-RailsYaniv Vova AltermanView Answer on Stackoverflow
Solution 2 - Ruby on-RailsHoa HoangView Answer on Stackoverflow
Solution 3 - Ruby on-Railsuser208769View Answer on Stackoverflow
Solution 4 - Ruby on-RailsCtpelnar1988View Answer on Stackoverflow
Solution 5 - Ruby on-RailsmridulaView Answer on Stackoverflow
Solution 6 - Ruby on-RailsWilliam HuView Answer on Stackoverflow
Solution 7 - Ruby on-RailsjeremywoertinkView Answer on Stackoverflow
Solution 8 - Ruby on-RailsfanjieqiView Answer on Stackoverflow
Solution 9 - Ruby on-RailsAndrew KosterView Answer on Stackoverflow