Plesk

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

Symptoms

Cause

Nginx's virtual host opens 4 log files for each virtual host with physical hosting:

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:

  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

Exit mobile version