Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vikasprogrammer/092ef68ce092cfa664f183a73a5dcb2a to your computer and use it in GitHub Desktop.
Save vikasprogrammer/092ef68ce092cfa664f183a73a5dcb2a to your computer and use it in GitHub Desktop.
Too many open files : Nginx (log)
ERROR:
++++++
2021/07/03 08:20:10 [alert] 8744#8744: setrlimit(RLIMIT_NOFILE, 2165535) failed (1: Operation not permitted)
2021/07/03 08:20:10 [alert] 8743#8743: setrlimit(RLIMIT_NOFILE, 2165535) failed (1: Operation not permitted)
2021/07/03 08:20:22 [alert] 8814#8814: setrlimit(RLIMIT_NOFILE, 2165535) failed (1: Operation not permitted)
2021/07/03 08:20:22 [alert] 8815#8815: setrlimit(RLIMIT_NOFILE, 2165535) failed (1: Operation not permitted)
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Workaround:
+++++++++++
#please note that I am using runcloud.io installation thats why nginx is nginx-rc, for your case it may very well be nginx only.
systemctl edit nginx-rc
#that will create the file /etc/systemd/system/nginx-rc.service.d/override.conf
#then add
[Service]
LimitNOFILE=1048576
LimitNPROC=1048576
#save and close
systemctl daemon-reload
systemctl restart nginx-rc
cd /
find / -name nginx.conf
#this command will give you the nginx.conf file path
nano /etc/nginx-rc/nginx.conf
#here, check the user line, in our case it was: user runcloud-www runcloud-www;
chown runcloud-www:runcloud-www nginx.conf
chown runcloud-www:runcloud-www nginx.conf.default
nano nginx.conf
#comment out worker_rlimit_nofile 2165535;
#save and close
sysctl -p /etc/sysctl.conf
nginx-rc -t
nginx-rc -S reload
systemctl restart nginx-rc.service
#after restart of nginx-rc.service, check tail -100f /var/log/nginx-rc/error.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment