java.net.SocketException: Too many open files

January 18, 2008 · Posted in java, linux 

For System Wide settings
To see the settings for maximum open files for the OS level, use following command.
cat /proc/sys/fs/file-max
This should be a value from 36000 to 50000 or more. To increase the system wide maximum open files, as root edit the /etc/sysctl.conf and add the following to the end of the file.

Note: The following example will increase the maximum number of files to 49,500 on your currently running system and will persist after rebooting.

fs.file-max = 49500

Then issue the following command to activate this change to your live system.
sysctl -p

For user level setting

Also, you should update /etc/security/limits.conf for the user.

myuser hard nofile 2048
myuser soft nofile 2048

Type this to see what it’s set at:

ulimit -a

Comments

One Response to “java.net.SocketException: Too many open files”

  1. Daniel on February 5th, 2009 2:22 PM

    Nice. Thanks for posting this.

    Daniel

Leave a Reply