Add the following lines in /etc/security/limits.conf file before # End of file line:
# tail -n4 /etc/security/limits.conf
* soft nofile 8192
* hard nofile 8192
The issue can come from different sources on your server. For Debian, for example, consider increasing the following values to avoid hitting open file limits (web server / mail / PHP):
/etc/security/limits.conf
Code:
* hard nofile 1048576
* soft nofile 1048576
root hard nofile 1048576
root soft nofile 1048576
/etc/sysctl.d/10-own-settings.conf
Code:
# Kernel 5.11 will raise those limits automatically based on host memory, but 5.10 is still using default low values: 8192 / 128
fs.inotify.max_user_watches = 560144
fs.inotify.max_user_instances = 1024
For other OSes, look for the corresponding settings. It also makes sense to monitor the configuration for changes, for example via Ansible, to make it more resilient.