How to fix accept() failed (24: Too many open files) error in Nginx
Sometimes using LEMP on a web server you can come across 500 error. If you check on logs you can see something like:
[alert] 8668#0: accept() failed (24: Too many open files)
This indicates that the amount of files opened at the same time is off limit.
To fix it add to /etc/security/limits.conf:
* soft nofile 16384 * hard nofile 16384
Run as root:
ulimit -n 16384Sudo will not work here.
It's also recommended to reboot the server, though it's not absolutely necessary.
In /etc/nginx/nginx.conf write:
worker_connections = 4096 worker_processes = 4
In case you didn't run ulimit -n 16384 command reboot the server.
This work is licensed under a Creative Commons Attribution-NoDerivs 3.0 United States License.
Got a comment?
All Rights Reserved.