Let me get all of the ulimit -n and /etc/security/limits.conf answers out of the way by saying this: I've tried setting ulimit -n to 2048, 4096, and 65535. I have set both the soft and hard limit for nofiles to all of those values. ulimit -n shows that it has been changed. But when running the server, it can still only have 1024 open sockets. accept is failing with errno 24 (too many open connections.)

After hours of googling, asking in #debian, and reading questions on ServerFault, I have still not found a solution. Why would ulimit -n show one number, but still be restricted to 1024 open file descriptors?

Some potentially useful information: The process is being started at the terminal in a screen, in su. Yes, I have added pam_limits.so to /etc/pam.d/su. I also added it to /etc/pam.d/common-session. Still no luck.

2 Answers 2


Nevermind, it turns out the problem was a combination of ulimit -n and FD_SETSIZE. It seems like the application is using setrlimit to set ulimit -n to FD_SETSIZE. I fixed this by undefining and redifining __FD_SETSIZE to something larger.

  • 3
    Are you able to elaborate on this a bit please?
    – UpTheCreek
    Jun 9, 2014 at 11:48

What does this command tell you?

sysctl fs.file-max

You might try:

sysctl -w fs.file-max=[bigger-number]

If that works, then add this to your /etc/sysctl.conf file:

fs.file-max = [bigger-number]
  • 1
    Sorry, no go. :( fs.file-max = 333605
    – Ramsey
    Sep 20, 2009 at 2:33

You must log in to answer this question.