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

I'm using CentOS 6.3 64bit, and having trouble with increase FD limitation: SSH not working after changed the limitation, every-times I logged on my server, after typed password, then "connection closed by remote server".

It's a remote server without any "rescue mode" so there's no way to do a local login to get any error log. I also tried ulimit -SHn before this issue happened but not work as well.

Now I have to restore snapshot every-time this issue happened, and still have no idea what's wrong with my server.

Since I'm working on a high performance server handling millions of requests per second, I need a very high FD limitation, here is my configuration:

* hard nofile 2000000
* soft nofile 2000000

*          soft    nproc     1024

Protocol 2
SyslogFacility AUTHPRIV
PasswordAuthentication yes
ChallengeResponseAuthentication no
GSSAPIAuthentication yes
GSSAPICleanupCredentials yes
UsePAM yes
X11Forwarding yes
Subsystem       sftp    /usr/libexec/openssh/sftp-server

auth       required
auth       include      password-auth
account    required
account    include      password-auth
password   include      password-auth
session    required close
session    required
session    required open env_params
session    optional force revoke
session    include      password-auth
session    required   

fs.file-max = 2000000
fs.nr_open = 2000000 
share|improve this question
You are perhaps reaching your process limit before reaching the file limit. That is, whatever is opening the files is also forking processes up to the limit and this prevents you from getting a login shell. Raise the process limit. – Jonathan Ben-Avraham Apr 9 '13 at 9:36
What is "process limit"? I'm not running any process on my server using huge amount of FDs for now. – Reck Hou Apr 9 '13 at 9:52
Please provide more details about what processes (services/daemons) are running on the server. – Jonathan Ben-Avraham Apr 9 '13 at 10:12
Just a new deployed system. If I use "* hard nofile 1024 * soft nofile 1024" after reboot everything is fine, so I don't think there's any process/service caused this issue. – Reck Hou Apr 9 '13 at 10:16

2^20 (approximately one million) is the maximum file descriptor limit (NR_OPEN) that's supported under Linux. It would take many changes, including recompiling the kernel, to raise it. It would also break lots of user space applications that rely on the limit being low.

I suspect you're completely barking up the wrong tree though. There's no correlation between request rate and number of file descriptors needed.

share|improve this answer
Do you have any evidence or example about "It would also break lots of user space applications that rely on the limit being low."? – Reck Hou Apr 9 '13 at 15:36
@ReckHou There was a patch to the Linux kernel to raise the limit and it was removed because of issues with user space applications. The main problem is that applications, typically before calling exec, close all descriptors that they might have open. If the limit is raised, this can take a very long time. One python script went from taking minutes to taking hours. This type of code is buried in libraries. (Think of posix_spawn(3p) and system(3).) – David Schwartz Apr 9 '13 at 15:41
2^20 limitation is not the end of world, see my answer below. But you also made a useful point, +1 for your answer. – Reck Hou Apr 12 '13 at 8:51
up vote 0 down vote accepted

Finally I found a way to overcome the 2^20 limitation without modify kernel source code:

In /etc/sysctl.conf:

fs.nr_open = 10485760

Modify fs.nr_open over 2^20 can solve this issue.

Moreover, the 2^20 limit is not the end of world. There's one person I know have successfully build a CentOS server very close to this limit, his record is 1025216 for now. If he use higher mem with correct configure, no doubt he can overcome this limitation easily.

Here is what he has done(written by Chinese but you can see his config):

share|improve this answer

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.