# Too many open files errors

**URL:** <https://www.ruby-forum.com/t/too-many-open-files-errors/124839>\
**Category:** NGINX\
**Created:** [January 3, 2008, 12:15am UTC](https://www.ruby-forum.com/t/too-many-open-files-errors/124839 "2008-01-03T00:15:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tuta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/a5b964/32.png) [@tuta](https://www.ruby-forum.com/u/tuta)\
**Post date:** [January 3, 2008, 12:15am UTC](https://www.ruby-forum.com/t/too-many-open-files-errors/124839/1 "2008-01-03T00:15:16Z")

</div>

Hello all ,  
nice to see a nginx topic on here 🙂 also greetings to mail-listers!

I have problem with nginx+fast-cgi. Sometimes CPU useage getting higher  
then %100. I checked error.log and found something.

On startup (nginx) , there is showing an error more then 5 like that;

2008/01/03 01:07:54 [alert] 12755#0: sendmsg() failed (9: Bad file  
descriptor)

After a few minutes later (10 or 15 minutes) , i am having Too many open  
files error too. Then cpu usage getting over %100 for a few minutes…  
also HTTP 500 error…

I am using Centos5 + 64bit with nginx-0.5.34 + fastcgi. Also this is a  
BitTorrent tracker.

I have reinstalled my box and i still having same problem.

Willing to get answered.  
Happy new year all!  
Regards!

---

<div class="post-metadata">

**Author:** ![tuta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/a5b964/32.png) [@tuta](https://www.ruby-forum.com/u/tuta)\
**Post date:** [January 3, 2008, 12:28am UTC](https://www.ruby-forum.com/t/too-many-open-files-errors/124839/2 "2008-01-03T00:28:42Z")

</div>

You’re probably hitting your OS’s file descriptor limit:

To check and modify system limits.  
% cat /proc/sys/fs/file-max

[To temporarily increase this to 65535 (as root)]

# echo “65535” \> /proc/sys/fs/file-max

If you want this new value to survive across reboots you can at it to  
/etc/sysctl.conf

# Maximum number of open files permited

fs.file-max = 65535

---

<div class="post-metadata">

**Author:** ![tuta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/a5b964/32.png) [@tuta](https://www.ruby-forum.com/u/tuta)\
**Post date:** [January 3, 2008, 12:32am UTC](https://www.ruby-forum.com/t/too-many-open-files-errors/124839/3 "2008-01-03T00:32:49Z")

</div>

I found that on nginx mail lists but cant understand what to do :\

* * *

Subject: Re: too many open files Re: too many open files

On 01.03.2006, at 11:31, L0rda wrote: On 01.03.2006, at 11:31, L0rda  
wrote:

> Good day,
> 
> narisovalas a problem nginx can not open more than 500 log files, the signal-HUP not overloading configuration, 24: Too many open files. 24 gives a mistake: Too many open files.
> 
> nginx.conf: worker\_rlimit\_nofile 15000; nginx.conf: worker\_rlimit\_nofile 15000;
> 
> df -i df-i  
> Filesystem Inodes IUsed IFree IUse% Mounted on Filesystem Inodes IUsed IFree IUse% Mounted on  
> /dev/sda1 15794176 840958 14953218 6% / / dev/sda1 15794176 840958 14953218 6% /  
> /dev/shm 219846 1 219845 1% /dev/shm / dev / shm 219846 1 219845 1% / dev / shm  
> /dev/sda2 1048576 15442 1033134 2% /var / dev/sda2 1048576 15442 1033134 2% / var
> 
> sysctl -a|grep file sysctl-a | grep file  
> fs.file-max = 500000 fs.file-max = 500000  
> fs.file-nr = 11820 0 500000 fs.file-nr = 11820 0 500000
> 
> ulimit -n 15000 ulimit-n 15000  
> To reload the configuration had to disable several log files.
> 
> Perhaps someone met with a similar problem?

---

<div class="post-metadata">

**Author:** ![tuta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/a5b964/32.png) [@tuta](https://www.ruby-forum.com/u/tuta)\
**Post date:** [January 3, 2008, 6:58pm UTC](https://www.ruby-forum.com/t/too-many-open-files-errors/124839/4 "2008-01-03T18:58:56Z")

</div>

On Thu, 2008-01-03 at 00:32 +0100, Mustafa T. wrote:

> I found that on nginx mail lists but cant understand what to do :\

Perhaps read Arash’s very, very clear and simple response one more  
time.

If you can’t follow those instructions, then you should probably seek a  
consultant or hire an administrator.

Cliff

---

<div class="post-metadata">

**Author:** ![tuta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/a5b964/32.png) [@tuta](https://www.ruby-forum.com/u/tuta)\
**Post date:** [January 3, 2008, 11:26pm UTC](https://www.ruby-forum.com/t/too-many-open-files-errors/124839/5 "2008-01-03T23:26:45Z")

</div>

Well the solution ,

add this line on nginx.conf!

> worker\_rlimit\_nofile 10240;

Greetings!
