Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 to /etc/pam.d/su. I also added it to /etc/pam.d/common-session. Still no luck.

share|improve this question

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.

share|improve this answer
Are you able to elaborate on this a bit please? – UpTheCreek Jun 9 '14 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]
share|improve this answer
Sorry, no go. :( fs.file-max = 333605 – Ramsey Sep 20 '09 at 2:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.