How to fix Nginx error “Too many open files”

nginx: [emerg] open() “/var/www/vhosts/” failed (24: Too many open files)
nginx: configuration file /etc/nginx/nginx.conf test failed
Please resolve the errors in web server configuration templates and generate the file again.

# echo ‘ULIMIT=”-n 4096″‘ >> /etc/sysconfig/nginx
# cp /etc/init.d/nginx /root/nginx.backup
# wget
# patch /etc/init.d/nginx nginx.redhat-centos.patch

# egrep “root|psaadm” /etc/security/limits.conf
root hard nofile 4096
root soft nofile 4096
psaadm hard nofile 4096
psaadm soft nofile 4096

Add line ulimit -n 32768 at the beginning of script /usr/local/psa/admin/sbin/nginx-config:
#!/usr/bin/env bash
ulimit -n 32768

Restart sw-cp-server and Nginx services:
# /etc/init.d/sw-cp-server restart
# /etc/init.d/nginx restart

Then regenerate web-server configuration:
# /usr/local/psa/admin/sbin/httpdmng –reconfigure-all

Leave a Reply