Passenger Cannot create a pipe: Too many open files (errno=24)

This morning one of my sites on Dreamhost shared hosting was returning this error page. It is Django / Python / Passenger based.

[code]Internal server error

An internal error occurred while trying to spawn the application.
Exception type: Passenger::SystemException
Error message: Cannot create a pipe: Too many open files (errno=24)
Backtrace:
in ‘virtual Passenger::ApplicationPool2::ProcessPtr Passenger::ApplicationPool2::DirectSpawner::spawn(const Passenger::ApplicationPool2::Options&)’ (DirectSpawner.h:155)
in ‘void Passenger::ApplicationPool2::Group::spawnThreadRealMain(const SpawnerPtr&, const Passenger::ApplicationPool2::Options&, unsigned int)’ (Implementation.cpp:956)
Error ID
Application root
/home/alastairpatrick/cefanalyzer.com
Environment (value of RAILS_ENV, RACK_ENV, WSGI_ENV, NODE_ENV and PASSENGER_APP_ENV)
production
User and groups
Unknown
Environment variables
Unknown
Ulimits
Unknown
Powered by Phusion Passenger, mod_rails / mod_rack for Apache and Nginx.[/code]

Static resources were still working but anything requiring Django would result in a 500 with this message.

I don’t know if this has anything to do with the recent switch from Debian to Ubuntu. I think maybe.

The solution was to go into the panel for the domain (Domains | Manage Domains | mysite.com | Edit) and turn Passenger off, wait a few minutes and turn it back on again. That seemed to reset Passenger somehow. It fixed another of my Passenger sites on the same server as well.

A tip to diagnose this Passenger issue. Add this line to “.bash_profile”:

Passenger runs things through bash if it’s your default shell so, if Passenger is working, a file with that name will be created / modified in the directory for the domain when Passenger does its thing. If it doesn’t appear then something is wrong.

Thanks for posting the steps Acamus. It would be nice to to pinpoint the cause of this problem. So it could be prevented in the future.