I have a problem: I am trying to test a demo server designed to deal with LOTS of simultaneous connections. And my tests fail at a small number because of socket.error: (24, ‘Too many open files’). I need to make the system let my test program open lots of sockets.

What are the current limits?

  • To obtain the current system-wide maximum number of file-descriptors-per-process, use 'cat /proc/sys/fs/file-max' or 'sysctl -a | grep fs.file-max'.
  • There is also a limit on how many file-descriptors a user may create: 'ulimit -n'

First we shall increase the system-wide limit: edit /etc/sysctl.conf and set the value of fs.file-max to the desired maximum. Run sysctl -p to effect the changes.

Now, let’s increase per-user limits. Edit /etc/security/limits.conf and put something like this at the bottom:

parijat hard nofile 400000

where ‘parijat’ is my login on this system. Logout and login again. ulimit -n should print 400000 now.

Leave a Reply