When programs start failing with Too many open files, the question is whether one process hit its own limit or the whole system ran out. One small file answers the second part.
cat /proc/sys/fs/file-nr
It prints three numbers. The kernel documentation calls them the number of allocated file handles, the number of allocated but unused handles, and the maximum. The middle one is always 0 on modern kernels, and the documentation stresses that this is not an error. So the first number against the third tells you how close the system is to its limit.
On most current systems the maximum is huge, often the largest 64 bit number, and you will never reach it. In that case a Too many open files error comes from the limit of a single process, which you can see in /proc/PID/limits or change for a service with LimitNOFILE= in its unit.
To find which process holds many files, count the entries in /proc:
for p in /proc/[0-9]*; do echo "$(ls $p/fd 2>/dev/null | wc -l) $(cat $p/comm 2>/dev/null)"; done | sort -rn | head
I’d run that with sudo, because otherwise you only see your own processes.
A count that keeps rising over days, while the load stays the same, points to a leak in one program, often sockets that are never closed. Raising fs.file-max only postpones that problem. Fix or restart the leaking program instead.
Further reading: Documentation for /proc/sys/fs/, proc_sys_fs(5) manual page