• We value your experience with Plesk during 2025
    Plesk strives to perform even better in 2026. To help us improve further, please answer a few questions about your experience with Plesk Obsidian 2025.
    Please take this short survey:

    https://survey.webpros.com/
  • On Plesk for Linux mod_status is disabled on upgrades to improve Apache security.
    This is a one-time operation that occurs during an upgrade. You can manually enable mod_status later if needed.

Issue AH01071 Failed to open stream: Too many open files in ...

JohnWest

New Pleskian
Server operating system version
Ubuntu 22.04.5 LTS
Plesk version and microupdate number
lesk Obsidian v18.0.64_build1800241008.13 os_Ubuntu 22.04
Hi All,

I've got a server with 3 domains on it.
Nothing too crazy here.

One of the website is recently experience error 500.
It seems to be that the site grew recently and I'm hitting an error I've not encountered before.

AH01071: Got error 'PHP message: Failed to open stream: Too many open files in ….
follow by bunch of files that errored out when a page load.

I'm not an expert so I checked online here and there, but it wasn't clear if the issue would be something I can fix with a per domain setting (some suggest NGINX level instruction), or Apache (domain level instructions), or apache module overall, or event the whole system.

What's certain is that when this error hits, only this domain is experiencing issues. Not the others on the same server. Which would point me towards a resolution that can be implemented with domain level settings.

Looking forward to hear about suggestions.
 
Dedicated FPM application served by nginx
PHP 8.5.2
memory_limit 256M
pm.max_children 10
pm dynamic
pm.start_servers 4
pm.min_spare_servers 2
pm.max_spare_servers 6

nginx settings

Proxy mode OFF
HTTP/3 support ON
Smart static files processing ON
Serve static files directly by nginx OFF
brotli ON
+ some Cache-Control

The error i get is
Failed to open stream: Too many open files in XXX
Failed to open directory: Too many open files in XXX

when i restart the PHP - all good and no errors at all

Now i added inside sysctl.conf
fs.file-max = 70000

and inside inside limits.conf
nginx soft nofile 10000
nginx hard nofile 30000
 
Thank you for the provided context.

I suspect the system user running the PHP code hits the default 1024 nofile limit.

You can increase the limit with /etc/sysctl.conf or /etc/sysctl.d/website_name and instead of nginx, set the system user used by the website (default FTP user)
You can also increase the nofile using an override for the dedicated PHP-FPM service. The FPM service name is ``plesk-php85-fpm_$domain.tld_$siteID.service``
Bash:
systemctl edit plesk-php85-fpm_$domain.tld_$siteID.service
add:
[Service]
LimitNOFILE=30000
Then restart the server
Bash:
systemctl restart plesk-php85-fpm_$domain.tld_$siteID.service
 
im on dedicated server with root access with ~50 domains/websites. I would like to have server solution instead of per domain.
Isnt this enough? -
Now i added inside sysctl.conf
fs.file-max = 70000

and inside limits.conf
nginx soft nofile 10000
nginx hard nofile 30000
 
im on dedicated server with root access with ~50 domains/websites. I would like to have server solution instead of per domain.
Isnt this enough? -
No, this is not enough, because it is not nginx which is hitting the limit but the php process, which runs as the domain user. Sou you have to raise the limits for all those domain users.
 
No, this is not enough, because it is not nginx which is hitting the limit but the php process, which runs as the domain user. Sou you have to raise the limits for all those domain users.
Fair enough. When i try the command from Raul i get "No files found for plesk-php85..." I tried with domain name and ftp user to exchange "domain.tld" and "siteID" is get from "smb/web/overview/id/6/". If i setup it is it valid for all 8.5.x itterations? If i change to php 8.6 do i have to redo it?
 
I managed to edit the file. For reference when i grep LimitNOFILE i get:
LimitNOFILE=524288
LimitNOFILESoft=1024

for all domains so i guess Soft was the problem - changed it to 30000
 
If i setup it is it valid for all 8.5.x itterations? If i change to php 8.6 do i have to redo it?
With the systemd approach, you have to redo it for a new version of php. With the limits.conf approach, you have to redo it for each new domain user.
 
Back
Top