Home > linux > How to fix: Too many open files

How to fix: Too many open files

Chances are you’ve came across this error “Too many open files” on a Linux system.  I’ve been getting this for as long as I can remember and now most recently on RHEL 5.  This error occurs when a user on a system is unable to open more than a certain number of files at a given time.  This means If you’re application is working on 50,000 files simultaneously, you’ll get this error.

To check what your system’s default value is:

$ ulimit -n
1024

To set it to a higher value and make it stick, say 51,200, edit /etc/security/limits.conf and add the following values at the bottom:

user   soft nofile  51,200
user  hard nofile  51,200

The first field on left hand side is the user that need to open as many as 51,200 files.  That’s it.

Categories: linux Tags:
  1. June 25th, 2010 at 09:32 | #1

    Terrific work! This is the type of information that should be shared around the web. Shame on the search engines for not positioning this post higher!

  2. Binod Suman
    March 1st, 2011 at 08:52 | #2

    Hi,

    Many many thanks. Thanks and only thanks. I was struggling last 2 days to solve this problem.

    Thanks again.

    Binod Suman

  3. Ramya
    May 19th, 2011 at 00:32 | #3

    Hi ,

    This doesn’t work for me.
    I am testing android-cts with Froyo.
    While testing/running the plan Java , in between the test it throws the error
    Cant write to ../../testResult.xml (Too many files open)
    Can anyone please help.
    Thanks in advance

  1. June 25th, 2010 at 01:51 | #1
  2. June 26th, 2010 at 08:07 | #2
  3. June 26th, 2010 at 09:29 | #3