When restarting a service, sometimes I see "Error: Too many open files".
Each server is provided with a maximum amount of files it can open. Depending on the environment, there are a few things to determine if you're being limited inside, or outside of your server.
The first thing we can do is run ulimit to see the current imposed limits.
Show soft limit:
This will tell us the current values set for the server. If this is an OpenVZ server, you can check beancounter with cat /proc/user_beancounters and here, you'll look for numproc:
# cat /proc/user_beancounters
If you see the failcnt increase for numproc, you'll want to check the host node or contact your hosting provider.
It's also a good idea to check what the system is saying you can use:
If that looks good, then also check for any limits in limits.conf.
grep -V "#"/etc/security/limits.conf
If there are no limits set in the limits file, and you haven't hit a "failcnt" for "numproc", you can edit the limit by using ulimit. As an example, to change open file limits, you can use ulimit -n
ulimit -n 8192 # set open files limit
If you need to change other limit values, please refer to the man page for additional details.