25

On Debian Wheezy, ulimit -a gives:

open files                      (-n) 1024

I add this to /etc/security/limits.conf

*                hard    nofile          64000

then reboot.

And ulimit -a still gives a maximum number of open files of 1024. Anyone could throw some light on it?

2
  • is this possibly a virtual host? Jul 4, 2014 at 9:49
  • no, it it's a mongodb server
    – Icu
    Jul 4, 2014 at 11:24

3 Answers 3

24

Option one: You did not set the softlimit higher aswell.

Possible solution:

in /etc/security/limits.conf add

* soft nofile 2048

test with

ulimit -n 2048 

Option two: You are logged in as user and in some "config" file (profile, bashrc, something like this) the soft limit is set to a lower value.

Possible solution f.e. grep for ulimit in your etc folder and/or home folder.

Warning: Depending on the amount of files/directorys you have in there you might want to consider only specific directorys/files

ps: there are a lot of similiar question here you might want to read up.

Specially Hard vs Soft Limit

Read here for possible other solution which go more into detail Too Many Open Files

5
  • 2
    Actually, I was trying to set only the hard limit to 64000. So the soft limit was still on 1024. Now I tried to set a soft limit to 64000 + hard = 72000. But it didn't work. I tried also "* - nofile 64000" and I get the same result.
    – Icu
    Jul 4, 2014 at 9:39
  • After having read "Too Many Open Files", I thought a kernel setting would be overriding the limits.conf settings but: "fs.file-max = 4933738"
    – Icu
    Jul 4, 2014 at 9:46
  • @Icu try the answers from this one aswell: serverfault.com/questions/93234/… might be related to your shell Jul 4, 2014 at 9:54
  • I added 'session required pam_limits.so' to /etc/pam.d/other and common-session but it doesn't help ... As an alternative, I added a 'ulimit -n' to my init script and it works but I wonder why I can't get the correct values in my shell.
    – Icu
    Jul 4, 2014 at 11:11
  • I think you meant: test with ulimit -a.
    – 842Mono
    Feb 13, 2022 at 6:33
26

There is a bug in Debian. To increase ulimit you need to add this into the /etc/pam.d/common-session file:

session required pam_limits.so

and in /etc/security/limits.conf add:

*               soft    nofile          65535
*               hard    nofile          65535

Then reboot the system.

7
  • 1
    no need for me to make any change to the /etc/pam.d/common-session file. it worked just by adding the other two lines to the limits.conf file :-) Jul 31, 2015 at 15:59
  • You shouldn't need to reboot. Mar 17, 2016 at 9:53
  • This is brutal. On debian 7 now, and this isn't working. Not sure what to do :( -- I might open a new question Jun 13, 2016 at 14:44
  • 13
    Boom. * wildcard doesn't work for root. I added root instead of *, and it's working. Thank you! Jun 13, 2016 at 15:25
  • @FrancescoCasula - which version of Debian was that? Just trying to figure out if this really is a bug, and if it still exists...
    – UpTheCreek
    Jan 10, 2018 at 14:57
1

In my case of Apache on Debian 10 the above didn't help though this worked:

echo "APACHE_ULIMIT_MAX_FILES='ulimit -n 16384'" >> /etc/apache2/envvars
service apache2 restart

I checked with:

cat /proc/$pid/limits

..where $pid is the process ID of one of the Apache processes.

You must log in to answer this question.

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