Applicable to:
- Plesk for Linux
Symptoms
-
The nginx service fails to start/reload with the following error in the
/var/log/nginx/error.log
file:CONFIG_TEXT: nginx: [emerg] open() "/var/www/vhosts/system/example.com/logs/proxy_access_ssl_log" failed (24: Too many open files)
-
Some or all websites are not accessible
-
Warning is shown in the Tools & Settings > Diagnose & repair:
PLESK_WARN: Checking for nginx ULIMIT value N domains have been found on server. Problem with nginx default limit for open files is possible
-
NodeJS and Ruby web applications are showing 502 Bad Gateway error when performing some Plesk tasks such as creating domains, subscriptions, changes on Apache or Nginx, etc:
CONFIG_TEXT: Server Error
502 Bad Gateway
Web server received an invalid response while acting as a gateway or proxy server. -
After installing a new certificate for the domain, the old one is still shown in a web browser, however, the correct certificate is selected at the Domains > example.com > Hosting Settings page.
Cause
Nginx's virtual host opens 4 log files for each virtual host with physical hosting:
- proxy_access_log
- proxy_access_ssl_log
- webmail_access_log
- webmail_access_ssl_log
As a result of this fact, the maximum number of open files is exceeded by the nginx server due to a big number of domains (usually, more than 100).
Resolution
Warning: Execution of the websrv_ulimits
utility without --no-restart option initiates rebuilding of web configuration files for all domains and can cause significant downtime in case of a big number of hosted websites.
Execute the command during the maintenance time frame.
It is good practice to set open files limit value more than number of domains in Plesk * 16 at least. In example below provided actions how to set limit to 4096:
-
Connect to the server via SSH
-
Set open files limit to 4096 for both Apache and Nginx:
# /usr/local/psa/admin/sbin/websrv_ulimits --set 4096 --no-restart
-
Restart Apache and nginx services at Plesk > Tools & Settings > Services Management to apply changes.
-
Check that 'Max open files limit' was applied properly, after web services restarting:
# grep 'Max open files' /proc/$(cat /var/run/nginx.pid)/limits
Max open files 4096 4096 file -
If the solution above did not help, set the limit using the
ulimit
utility:# ulimit -n 4096
Comments
12 comments
to reduce the limit? If I try to increase it works if instead I want to reduce it it doesn't work.
Hello Dario D'Orazi
The idea of the resolution is to increase the limit.
4096 is more when the default value.
The value is to be set more than number of domains in Plesk * 16 at least.
So, you did everything correctly when increasing the value.
Hello Ivan,
by typing mistake I increased the value to 40960 and I would like to lower it but I can't
Hi @Dario D'Orazi,
In order to decrease the value, please adjust it manually:
1. Update value LimitNOFILE in files /usr/lib/systemd/system/httpd.service.d/limit_nofile.conf and /usr/lib/systemd/system/nginx.service.d/limit_nofile.conf
2. Update value worker_rlimit_nofile in /etc/nginx/ulimit.global_params
3. Restart Nginx and Apache services:
# systemctl daemon-reload
# systemctl restart nginx
# systemctl restart httpd
Здравствуйте ! Я выполнил действия по данной инструкции и установил ограничения 6000 файлов притом что доменов 276, и все равно получаю ошибку. В чем может быть проблема ? спасибо!
Sometimes all these solutions dont work. I had this problem on CentOS 8 and it turned out SELinux was preventing the
changed limits. The following command helped: setsebool -P httpd_setrlimit 1
Hello Jonas Frey
Thank you for letting us know.
Сергей Засухин
В вашем случае это выклядит как предупреждение, если больше нет никаких ошибок, то можно не беспокоиться.
For a new server with CentOS 8.2 with Plesk Obsidian 18.0.29 (installed was 18.0.28#3) there is no limits set
# /usr/local/psa/admin/sbin/websrv_ulimits --get
nginx:-1
apache:-1
Is this a bug? Because with this I get this error:
Checking for nginx ULIMIT value 2 domains have been found on server
Hello @Karl May
Indeed this warning may occur and this is considered as a bug #PPP-47989. However this bug is cosmetic one and the warning can be safely ignored.
This article and the Plesk warning message are both confusing.
On a NEW Plesk server on CentOS 8.2, I get these results.
# /usr/local/psa/admin/sbin/websrv_ulimits --get
nginx:-1
apache:-1
# grep 'Max open files' /proc/$(cat /var/run/nginx.pid)/limits
Max open files 1024 262144 files
Plesk displays a warning that the ulimit is too low and needs to be increased.
So after I execute: /usr/local/psa/admin/sbin/websrv_ulimits --set 4096 --no-restart
Then the results are:
# /usr/local/psa/admin/sbin/websrv_ulimits --get
nginx:4096
apache:4096
# grep 'Max open files' /proc/$(cat /var/run/nginx.pid)/limits
Max open files 4096 4096 files
But is that actually now correct? Or have I now created a new problem?
So are these instructions required at all for CentOS 8? Because I suspect the answer is "no" and in fact running that Plesk command should "not be recommended".
If that's the case, then this article needs to be improved.
I get this behavior when I only have 2 sites on my VM. Should I also bump this up to 4096?
Hello,
Agilehost Sales
"-1" should mean no limit, so the warning should be false-positive. On the other hand, #PPP-47989 should be fixed in recent Obsidian updates,
As I can see, you've already had some support requests submitted to us. Could you contact Plesk Support to have this issue checked?
Stuart Liedtke
The value is calculated this way: number of domains in Plesk * 16
Please sign in to leave a comment.