My configuration in /etc/security/limits.conf is

* soft nofile 60000
* hard nofile 60000

I run nginx in ubuntu.after reboot the ubuntu, ulimit -n is 60000, but

cat /proc/`ps -elf | grep nginx | grep 'master process' | awk '{print $4}'`/limits| grep 'open files'

the answer is 1024, why not 60000?

1 Answer 1


/etc/security/limits.conf is read by the PAM module pam_limits.so at login.

But when nginx is started at boot, it never passes through a login procedure, so PAM never has a chance to make any ulimit changes to the nginx process or any of its parent processes.

If your nginx is started by a script, then you should add the ulimit commands to the script:

ulimit -H -n 60000
ulimit -S -n 60000

If nginx is started by a systemd .service file, use systemctl edit nginx.service, and add this line to the [Service] section of the file:


systemctl edit some.service will automatically take the original service file from [/usr]/lib/systemd tree and place the modified version under /etc/systemd instead. Any files in /etc/systemd will override any files with the same name located in [/usr]/lib/systemd tree.

It will also cause the service configuration to be automatically reloaded, so you don't need to use systemctl daemon-reload manually.

  • 1
    You should use systemctl edit foo.service instead of manually copy-creating override files.
    – muru
    Mar 6, 2018 at 7:21
  • Good point, edited my answer.
    – telcoM
    Mar 6, 2018 at 7:35
  • Beaten by muru. I was going to say the same. And also note that you missed out an Upstart job file, the actual most likely alternative to a systemd unit. There's a lot more on this subject on AskUbuntu. Witness askubuntu.com/questions/941617 , askubuntu.com/questions/635110 , and many others.
    – JdeBP
    Mar 6, 2018 at 7:45
  • I'm actually not too familiar with Upstart as used on Ubuntu; feel free to edit my answer to add specifics on Upstart.
    – telcoM
    Mar 6, 2018 at 7:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.