Quantcast
Channel: myVesta
Viewing all articles
Browse latest Browse all 285

nginx templates • How to Fix “Too Many Open Files” Error in Nginx

$
0
0
When hosting many websites on a myVesta server, Nginx may eventually hit the system-imposed limit on the number of simultaneously open files. This can cause the web server to fail with the following error message:

Code:

[emerg] ... open() "... .error.log" failed (24: Too many open files)
This happens when the NOFILE (number of open files) limit is too low for the number of virtual hosts or log files being accessed.

Solution:

To raise the limit without overwriting existing configuration, first check if the override file already exists:

Code:

if [ ! -f "/etc/systemd/system/nginx.service.d/limits.conf" ]; then    mkdir -p /etc/systemd/system/nginx.service.d/    echo "[Service]" > /etc/systemd/system/nginx.service.d/limits.conf    echo "LimitNOFILE=65535" >> /etc/systemd/system/nginx.service.d/limits.conffi
If /etc/systemd/system/nginx.service.d/limits.conf already exists, edit it manually and add or adjust the LimitNOFILE value to at least 65535 or some value which suits you

Then apply the changes:

Code:

systemctl daemon-reexecsystemctl daemon-reloadsystemctl restart nginx

Statistics: Posted by isscbta — Mon Apr 07, 2025 3:56 pm



Viewing all articles
Browse latest Browse all 285

Trending Articles