Ubuntu – How to increase max open files limit on Ubuntu 18.04

18.04resource-limitingsystemulimit

I've run ulimit -n 65536, added the following lines to /etc/security/limits.conf:

*    soft nofile 65536
*    hard nofile 65536
alix soft nofile 65536
alix hard nofile 65536
root soft nofile 65536
root hard nofile 65536

And added session required pam_limits.so to both:

  • /etc/pam.d/common-session
  • /etc/pam.d/common-session-noninteractive

And fs.file-max = 65536 to /etc/sysctl.d/60-file-max.conf.

Still, after restarting and running ulimit -n on my session, I only get 4096 (was 1024 before).

What am I missing?

Best Answer

From the manual:

 -n     The maximum number of open file descriptors (most
        systems do not allow this value to be set)

systemd has an option for this:

$ more /etc/systemd/system.conf | grep NOFILE
#DefaultLimitNOFILE=

But this is also only for the graphical user settings. Remove the # and you can set it to 65536.

Comment from Daniel Fernández:

DefaultLimitNOFILE=65536 

might also be needed in

/etc/systemd/user.conf 
Related Question