Addressing an error of Too many open files I was attempting to follow the suggestions here

Although /etc/sysctl.conf

fs.file-max = 70000
vm.swappiness = 10

and /etc/security/limits.conf

nginx       soft    nofile  10000
nginx       hard    nofile  30000

following changes to the sysctl command the errors are identical and

user@mo:~$ ulimit -Hn
user@mo:~$ ulimit -Sn

Ubuntu 14.04 environment. /etc/nginx/nginx.conf

events {
        worker_connections 1024;
        passenger_enabled on;
        rails_env    development;
        root         /home/user/app/current/public;

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;

        location / {
            # proxy to upstream server
            proxy_redirect default;

            # track uploads in the 'proxied' zone
            # remember connections for 30s after they finished
            track_uploads proxied 30s;

        location ^~ /progress {
            # report uploads tracked in the 'proxied' zone
            report_uploads proxied;


update as suggested /etc/pam.d/common-session [...]

session required        pam_unix.so
session optional        pam_systemd.so

session required pam_limits.so

1 Answer 1


You need to complete some more steps to increase max open files in ubuntu.

  1. Edit /etc/pam.d/common-session and append below line

session required pam_limits.so

  1. Restart your system to apply the changes.

You can set limits to all users on system by adding below lines.

*       soft    nofile  10000
*       hard    nofile  30000

And reboot the system.

  • Tried that. ulimits are unchanged
    – Jerome
    Nov 20, 2014 at 9:43
  • @Jerome You have increased ulimit of "nginx" user, and I can see you are checking limit of "user" on console... Please send the output of ---- sudo -H -u nginx bash -c "ulimit -n" Nov 20, 2014 at 9:56
  • sudo -H -u nginx bash -c "ulimit -n" [] sudo: unknown user: nginx [] sudo: unable to initialize policy plugin
    – Jerome
    Nov 20, 2014 at 10:03
  • @Jerome Please make sure user "nginx" present on your system, check user with the command -- id -u nginx ....... default user of nginx is "www-data" on ubuntu system, so you may have to set limit for the user which is running your nginx daemon Nov 20, 2014 at 10:08
  • Instructive, as I'm not into digging into the OS. I had actually commented out that line in the nginx.conf file, not understanding the point. nginx is restarted. If I do sudo -H -u www-data bash -c "ulimit -n" I get the same # of processes (1024). Should I conclude that /etc/security/limits.conf should be defining those limits for "www-data"?
    – Jerome
    Nov 20, 2014 at 10:28

You must log in to answer this question.

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