Unable to start PHP-FPM: Too many open files (24)

Created:

2016-12-12 03:40:02 UTC

Modified:

2017-08-08 13:16:55 UTC

4

Was this article helpful?


Have more questions?

Submit a request

Unable to start PHP-FPM: Too many open files (24)

Applicable to:

  • Plesk 12.5 for Linux

Symptoms

Unable to start PHP-FPM service:

# systemctl status plesk-php56-fpm.service
● plesk-php56-fpm.service - The PHP 5.6.27 FastCGI Process Manager
Loaded: loaded (/lib/systemd/system/plesk-php56-fpm.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Mit 2016-10-26 23:24:29 CEST; 5s ago
Process: 3517 ExecStart=/opt/plesk/php/5.6/sbin/php-fpm --nodaemonize (code=exited, status=78)
Main PID: 3517 (code=exited, status=78)

Okt 26 23:24:28 server systemd[1]: Starting The PHP 5.6.27 FastCGI Process Manager...
Okt 26 23:24:29 server php-fpm[3517]: [26-Oct-2016 23:24:29] ERROR: [pool example.com] cannot get uid for user 'root': Too many open files (24)
Okt 26 23:24:29 server php-fpm[3517]: [26-Oct-2016 23:24:29] ERROR: FPM initialization failed
Okt 26 23:24:29 server systemd[1]: plesk-php56-fpm.service: Main process exited, code=exited, status=78/n/

Or:

    systemd[1]: Starting The PHP FastCGI Process Manager...
php-fpm[1392]: [29-Nov-2016 16:09:24] ERROR: Unable to create the PID file (/run/php-fpm/php-fpm.pid).: Too many open files (24)

Domain might be migrated without hosting:

ERR [util_exec] proc_close() failed ['/usr/local/psa/admin/bin/phpinimng' '--type' 'fpm' '--virtual-host' 'example.com' '--service' 'php-fpm' '--poold' '/etc/php-fpm.d' '--remove'] with exit code [1]
An error occurred during domain creation: An error occurred during changing of hosting settings: phpinimng failed: Job for php-fpm.service failed because the control process exited with error code. See "systemctl status php-fpm.service" and "journalctl -xe" for details.
Failed to start php-fpm service

Website which is using php-fpm handler is not loading, the following errors can be found in /var/www/vhosts/example.com/error_log file:

ERROR: failed to prepare the stdout pipe: Too many open files (24)
ERROR: failed to prepare the stdout pipe: Too many open files (24)
ERROR: failed to prepare the stdout pipe: Too many open files (24)

Cause

Open file descriptor rlimit is exceeded.

Resolution

Determine what php-fpm.conf file is using. For PHP by OS vendor:

# php-fpm --test
NOTICE: configuration file /etc/php-fpm.conf test is successful

For PHP by Plesk (replace "PHP_version" with the actual version in use):

# /opt/plesk/php/PHP_version/sbin/php-fpm --test
NOTICE: configuration file /opt/plesk/php/PHP_version/etc/php-fpm.conf test is successful

Add string below to the configuration file from step 1 (to either /etc/php-fpm.conf or /opt/plesk/php/PHP_version/etc/php-fpm.conf):

rlimit_files = 4096
Have more questions? Submit a request

3 Comments

  • 0
    Avatar
    Peter Debik

    Tested with 1018 subscriptions on PHP 7.0 FPM. On creation of no. 1018 through the client utility:

    ERR [util_exec] proc_close() failed ['/usr/local/psa/admin/bin/phpinimng' '--type' 'fpm' '--service' 'plesk-php70-fpm' '--poold' '/opt/plesk/php/7.0/etc/php-fpm.d' '--restart'] with exit code [1]
    [2017-06-12 16:27:01] ERR [panel] Remove PHP-FPM config for <domain.tld> due to service failure: phpinimng failed: Job for plesk-php70-fpm.service failed because the control process exited with error code. See "systemctl status plesk-php70-fpm.service" and "journalctl -xe" for details.
    Failed to reload plesk-php70-fpm service

    But: Same command executed standalone on the console:
    # /usr/local/psa/admin/bin/phpinimng '--type' 'fpm' '--service' 'plesk-php70-fpm' '--poold' '/opt/plesk/php/7.0/etc/php-fpm.d' '--restart'
    restarts the service without problems.

    So likely it not sufficient to add the rlimit-directive to the PHP FPM configuration file, but Plesk needs some upgraded open files limit, too. nginx, psaadm can open 500000 files, too, what else could be causing this?

  • 0
    Avatar
    Peter Debik

    The article must be updated. The correct file location is not given by the

    # php-fpm --test

    command, because that only gives the location of the OS vendor's default PHP FPM service. However, for Plesk the relevant files are located here:

    /opt/plesk/php/<PHP version>/etc/php-fpm.conf

    So changing rlimit_conf in the OS vendor's PHP version will do nothing for actual Plesk webspace usage as most users will not use the outdated vendor versions, but the PHP versions that come with Plesk. After I have edited the "correct" php-fpm.conf file and restarted the service, the client for creating a subscription no longer gives a "open files" limit error as stated in the previous post.

    Edited by Peter Debik
  • 0
    Avatar
    Yulia Plokhotnikova

    Thanks Peter, your comments help a lot! I corrected the article.

Please sign in to leave a comment.