Site is going down!

We’re seeing a periodical error that is killing our application, causing us to have to restart Nginx every hour or so. This is what I’m seeing in my Nginx log:

An error occurred while starting up the preloader: it did not write a startup response in time. Error ID: 0a001263 Error details saved to: /tmp/passenger-error-UJeUgm.html Message from application: An error occurred while starting up the preloader: it did not write a startup response in time. Please read [this](https://github.com/phusion/passenger/wiki/Debugging-application-startup-problems) article for more information about this problem.

How can I solve this? Thanks.

The error: “Could not spawn process for application /var/deploy/thny/web_head/current: An error occurred while starting up the preloader: it did not write a startup response in time” is generated within Passenger - the problem is that your application code is taking too long to start.

Passenger has a default timeout of 90 seconds, see this article for more information about this problem:

It could also be that your server is so busy doing something (either CPU-wise or disk-wise) that it fails to start an application process within a reasonable amount of time. The default startup limit is 90 seconds. Solution for this problem: Change the timeout with one of the following configuration options: Apache: PassengerStartTimeout Nginx: passenger_start_timeout These configuration options have been introduced in version 4.0.15.

To test your application start time, you can go on your server and try the following: cd $STACK_PATH time bundle exec rails c exit

This allows you to check how long your application is taking to load. There are a couple of things you can do to resolve this:

  1. Optimize your application start time - ie. make initializer code asynchronous, or load on first request etc.
  2. Upgrade your version of Ruby - eg. Ruby v1.9.3 is a lot slower than Ruby v2.1.3 - and does not have a lot of the optimizations. As an example, when we upgraded our stack to Ruby v2.1.3, our stack start time went from 1 minute to 10 seconds
  3. Add the passenger_start_timeout variable to your Nginx CustomConfig - and increase the wait time to more than 90 seconds
  4. Throw more horsepower at it and increase your server CPU/MEM size

Notes: For option 2, I recommend building a new development stack first and ensuring your application works with Ruby 2.1.3. Then you can either upgrade your existing stacks in-place, or create new production ones (but please be aware the caveats

For option 3, this is not a good option to keep indefinitely as your application start times will just get longer potentially - but you may want to do this as a temporary measure.

You must be logged in to answer this question