8

I have a systemd user service with LimitNOFILE set. The value is respected until it hits 4096. After that point, it's capped to 4096. I've also tried increasing DefaultLimitNOFILE in /etc/systemd/user.conf.

It's set correctly in limits.conf, which works for new shells out of the box. Though, I heard systemd doesn't care about that file. What could be the problem?

3 Answers 3

11

Late answer; limits.conf is not used when systemd is running (limits.conf is for non-systemd systems).

The file you actually want is; /etc/systemd/system.conf - this is the global config. Then you have /etc/systemd/user.conf - this specifies further per-user restrictions.

Specifically in your case; even though you have configured user.conf with a higher limit, this is not valid as the limit in system.conf is lower, and acts as a cap on the limit in user.conf

O_O

2

From man systemd.exec:

For system units these resource limits may be chosen freely. For user units however (i.e. units run by a per-user instance of systemd(1)), these limits are bound by (possibly more restrictive) per-user limits enforced by the OS.

Your system probably has a configured hard limit of 4096 open files per process. It would open up a loophole if systemd allowed you to bypass this limit.

1
  • Thanks for the man page reference. I'm not sure that's quite it since I have limits.conf configured, but it should get me further troubleshooting. Jul 31, 2017 at 13:38
0

This might be related to systemd prior to version 240:

See: https://github.com/systemd/systemd/blob/main/NEWS

CHANGES WITH 240: ...

  • The Linux kernel's current default RLIMIT_NOFILE resource limit for userspace processes is set to 1024 (soft) and 4096 (hard). Previously, systemd passed this on unmodified to all processes it forked off. With this systemd release the hard limit systemd passes on is increased to 512K, overriding the kernel's defaults and substantially increasing the number of simultaneous file descriptors unprivileged userspace processes can allocate ...

So try to upgrade your systemd to version 240 or later

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .