Too many open files with nginx, can't seem to raise limit

Solution 1:

Add the following line to your nginx and restart the process:

worker_rlimit_nofile 30000;

This will allow the workers to take on more files. You can then verify with:

su - nobody
ulimit -Hn
ulimit -Sn

This should output the new hard/soft limits.

Reference

Solution 2:

In Ubuntu, edit /etc/pam.d/su add or uncomment the line session required pam_limits.so

Also, in /etc/security/limits.conf make sure you have TABS between the characters and not spaces.