A systemd-managed service logs accept: too many open files. You run ulimit -n 65536 as root, restart the service, and it fails again within minutes. Why, and what is the fix?
- The service leaks descriptors, so no limit helps. Possibly, but the limit was never applied; verify /proc/
/limits first. - fs.file-max is too low. That would give ENFILE ('file table overflow'), and it is a system-wide symptom.
- You must reboot for ulimit changes to take effect. Limits apply at process start; a correctly configured unit takes effect on restart.
- The shell's ulimit only affects that shell's children; the service inherits limits from its unit. Set
LimitNOFILE=65536in the unit (or a drop-in),systemctl daemon-reload, restart, and confirm in /proc//limits. Limits are per process and inherited from the launcher; systemd is the launcher.
The service inherits limits from systemd, not from your shell; set LimitNOFILE= in the unit, daemon-reload, restart and check /proc/
The diagnostic that ends the argument is cat /proc/$(pidof svc)/limits: if it still says 1024, the change did not reach the process. Then check ls /proc/<pid>/fd | wc -l over time to decide whether the new limit is enough or a leak exists.
Running ulimit -n in a root shell and believing the service got it. That shell's children got it; systemd's did not.