/etc/security/limits.conf not applied

https://superuser.com/questions/1200539/cannot-increase-open-file-limit-past-4096-ubuntu/1200818#=

There's a bug since Ubuntu 16 apparently.

Basically:

  1. Edit /etc/systemd/user.conf for the soft limit, and add DefaultLimitNOFILE=1048576.
  2. Edit /etc/systemd/system.conf for the soft limit, and add DefaultLimitNOFILE=2097152.

Credit goes to @mkasberg.


An alternative for those who prefer not to edit the default /etc/systemd/system.conf and /etc/systemd/user/conf files:

  1. create a new file /etc/systemd/system.conf.d/limits.conf with these contents:

    [Manager]
    DefaultLimitNOFILE=1048576:2097152
    DefaultLimitNPROC=262144:524288
    
  2. run systemctl daemon-reexec as root

  3. logout and login again

  4. check your new limits with either ulimit -a or ulimit -n and ulimit -u for max open files and max processes, respectively.

Refer to the systemd-system.conf manpage for details.

Tags:

Limit

Ulimit