The way to over come this problem is to increase the file limit of the OS.
First, in order to set this options automatically you have to edit the etc/security/limits.conf file.
$sudo gedit /etc/security/limits.conf
with the above command you can open the "limits.conf" file with gedit.
We need to set the nofile option meaning maximum number of open files.If you want to change the number of files of user, you should add this line in the limits.conf file.
Lets say our user name is "foo"
Then the entry should be
foo soft nofile 9000
foo hard nofile 65000
If you want to set the nofile only for superuser you just write root instead of user.
root soft nofile 9000
root hard nofile 65000
Now after rebooting you can see in the terminal with ulimit -a the change.