Articles in this section

nginx fails to start/reload on a Plesk server: Too many open files

Plesk for Linux kb: technical ABT: Group A

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

If more than 33 domains live on the server the ulimit should get increased automatically. There is a bug ID PPPM-14951 when the ulimit is automatically increased due to the number of domains: the nginx and Apache service are not restarted, and as a result, the new ulimit does not take effect for the running NGINX process.

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:

  1. Connect to the server via SSH

  2. Set open files limit to 4096 for both Apache and Nginx:

    # /usr/local/psa/admin/sbin/websrv_ulimits --set 4096 --no-restart

  3. Restart Apache and nginx services at Plesk > Tools & Settings > Services Management to apply changes.

  4. 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

  5. If the solution above did not help, set the limit using the ulimit utility:

    # ulimit -n 4096

Was this article helpful?

Comments

2 comments
Date Votes
  • Me sigue mostrando el error

    0
  • The error persists:

    # ulimit
    unlimited

    # grep 'Max open files' /proc/$(cat /var/run/nginx.pid)/limits
    Max open files            40960                40960                files

    # nginx -t
    nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
    nginx: [emerg] open() "/var/www/vhosts/system/<REDACTED>/logs/proxy_access_ssl_log" failed (24: Too many open files)
    nginx: configuration file /etc/nginx/nginx.conf test failed

    0

Please sign in to leave a comment.