The log files contains the error, "Too many files," and AEM doesn't respond.


The cause is one of two possiblities:

  • The application isn't closing resources such as files or sockets after using them.
  • Or the application requires more open files than is permitted by the process.


The solution to this problem is:

  1. Find out what is causing the open file limit to be reached
  2. Either increase the limit or fix the application bugs.

Find which files or sockets left open

** Note that open file limits apply to total combined open files, pipes and sockets, not just files.

On Linux platform, the lsof command can be used to debug which resources are held open by the process.

Here is a sample script to collect useful lsof output:

if [ $# -eq 0 ]
    echo "No PID specified"
    echo "Run command with PID, for example:"
    echo " 12345"
    exit 2


lsof -p $JAVA_PROCESS_PID > lsof-output-$JAVA_PROCESS_PID.txt

echo "Files open by the process:"
cat lsof-output-$JAVA_PROCESS_PID.txt |  wc -l

echo "Generated output file with counts of grouped open files lsof-sorted-counts-$JAVA_PROCESS_PID.txt"
cat lsof-output-$JAVA_PROCESS_PID.txt | awk '{print $9}' | sed -e "s/\(^.*\)\(segmentstore\).*$/\1\2/" |  sed -e "s/\(^.*\)\(repository[/]index\).*$/\1\2/" | sed -e "s/\(^.*\)\(felix[/]bundle\).*$/\1\2/" |  sed -e "s/\(^.*\)\([/]lib\).*$/\1\2/" |  sed -e "s/\(^.*\)\([/]logs\).*$/\1\2/" |  sed -e "s/\(^.*\)\([/]ext\).*$/\1\2/" | sort | uniq -c | sort -rn -k1 > lsof-sorted-counts-$JAVA_PROCESS_PID.txt

echo "Total open files in OS:"
lsof | wc -l

Sample output:

$> ./ 18070
Files open by the process:
Generated output file with counts of grouped open files: lsof-sorted-counts-18070.txt
Total open files in OS:

Inspect the output of the generated lsof-sorted-counts-*.txt file.  It shows which files or sockets are currently held open by the process.

If you find open sockets or files listed that shouldn't still be open then it is likely due to an application bug.  Update your application code to close files and sockets after using them.

A common cause of lingering open sockets is custom code that makes web service.  In many cases, libraries like Apache Commons HttpClient is used but connections are never closed by the developers.  See this article for details on Apache Commons HttpClient.

Increase the limit for the shell session

Check the user's limit for maximum open files, and then run the following as the same user that AEM process runs as:

ulimit -Sn ulimit -Hn

When using the default start script of AEM/CQ, do the following to increase the limit:

  1. Open crx-quickstart/bin/start for editing
  2. Add the variable CQ_MAX_OPEN_FILES to the top of the script:


If you see the error "-bash: ulimit: open files: cannot modify limit: Operation not permitted" when starting AEM, then the configuration above doesn't work.

Instead, it's necessary to increase the limit in /etc/security/limits.conf. See below for details on how to reconfigure the user limit.

If you are using a third-party application server such as JBoss or Websphere, follow the sections below and verify with the vendor's documentation.


If none of the configurations in this article solve the problem, then see what files are open using the command lsof -p. (-p is the process id of the problematic process.) It could be that your application is leaving file handles open. If you see that the handles are being held mostly by AEM and not your application, then contact support.

Increase the user's limits

To change the maximum number of open files for non-root users, change the file /etc/security/limits.conf. You can set the limit on a per-user basis:

crx_process_username soft nofile 8092

crx_process_username hard nofile 20000


This configuration doesn't take effect until the next time the user logs in.

Increase the system limit

Sometimes, the user limit is high enough, but the system itself has hit its maximum number of files. Run the following as su/root user:

  1. Check the max open file setting on the operating system (if it is below 20000, then it makes sense to increase this setting).

    cat /proc/sys/fs/file-max

  2. Add this line to /etc/sysctl.conf to increase the system open file maximum value:

    fs.file-max = 300000

  3. Run this command:

    sysctl -p

  4. Verify that the new value is displayed when you run this command:

    cat /proc/sys/fs/file-max


This configuration doesn't take effect until the next time the user logs in.

Additional information

This error occurs when the system or user is using its maximum number file handles.


This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy