We're running a Rails app in Passenger 4.0.45 and nginx 1.6.0 (installed by Passenger installer) running on Ubuntu 14.04. Under heavy load Passenger restarts all of the application processes. After enabling passenger debug logs, I found "Cannot accept client: Too many open files (errno=24)" errors in the Passenger logs.
Nginx is configured with "worker_rlimit_nofile 200000". Using cat /proc/pid/limits
I'm able to confirm that nginx has the correct limits. Our Rails app running in Passenger, however, is not getting a higher limit.
I've added to /etc/security/limits.conf
to give all users a high limit, and I've added session required pam_limits.so
to both /etc/pam.d/common-session
and /etc/pam.d/common-session-noninteractive` and restarted.
I can run
su appuser --shell /bin/bash --command "ulimit -n"
and I get a high number.
I finally tried setting the limit within the Rails app by adding the following to an initializer:
Process.setrlimit(Process::RLIMIT_NOFILE, 65535)
The result is:
Operation not permitted - setrlimit (Errno::EPERM)