# Too many open files

**URL:** <https://www.ruby-forum.com/t/too-many-open-files/175290>\
**Category:** NGINX\
**Created:** [September 10, 2009, 5:20pm UTC](https://www.ruby-forum.com/t/too-many-open-files/175290 "2009-09-10T17:20:25Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![iberci](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/a3d4f5/32.png) [@iberci](https://www.ruby-forum.com/u/iberci)\
**Post date:** [September 10, 2009, 5:20pm UTC](https://www.ruby-forum.com/t/too-many-open-files/175290/1 "2009-09-10T17:20:25Z")

</div>

how to handle?

2009/09/10 10:09:30 [alert] 9691#0: accept() failed (24: Too many open  
files)

---

<div class="post-metadata">

**Author:** ![iberci](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/a3d4f5/32.png) [@iberci](https://www.ruby-forum.com/u/iberci)\
**Post date:** [September 10, 2009, 5:23pm UTC](https://www.ruby-forum.com/t/too-many-open-files/175290/2 "2009-09-10T17:23:56Z")

</div>

i would start with google, look up the “how to ask smart questions”

and if you founded it and read it come back to the list.

but from the level of details you gave i presume you are a newbie linux  
administrator and founded the 1024 limitation in linux.

to get over it modify the limits.conf in /etc/security/ and I presume  
you  
are using ubuntu so modify the /etc/pam.d/login and include the  
pam\_limits.so with full path

🙂

---

<div class="post-metadata">

**Author:** ![iberci](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/a3d4f5/32.png) [@iberci](https://www.ruby-forum.com/u/iberci)\
**Post date:** [September 10, 2009, 5:35pm UTC](https://www.ruby-forum.com/t/too-many-open-files/175290/3 "2009-09-10T17:35:38Z")

</div>

Yes, newbie to linux (a year into it, still learning every day).  
I searched on Google but am unclear on server settings that impact this  
vs.  
nginx settings and what the numbers should be, etc.

---

<div class="post-metadata">

**Author:** ![iberci](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/a3d4f5/32.png) [@iberci](https://www.ruby-forum.com/u/iberci)\
**Post date:** [September 10, 2009, 5:36pm UTC](https://www.ruby-forum.com/t/too-many-open-files/175290/4 "2009-09-10T17:36:14Z")

</div>

put a ulimit -n 65000 or something like that in /etc/sysconfig/nginx or  
depending on the distro into the nginx init script

greets

---

<div class="post-metadata">

**Author:** ![iberci](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/a3d4f5/32.png) [@iberci](https://www.ruby-forum.com/u/iberci)\
**Post date:** [September 10, 2009, 5:37pm UTC](https://www.ruby-forum.com/t/too-many-open-files/175290/5 "2009-09-10T17:37:59Z")

</div>

Hello!

On Thu, Sep 10, 2009 at 11:10:28AM -0400, Ilan B. wrote:

> how to handle?
> 
> 2009/09/10 10:09:30 [alert] 9691#0: accept() failed (24: Too many open  
> files)

You have to tune your OS. Under FreeBSD:

sysctl kern.maxfiles=65535  
sysctl kern.maxfilesperproc=60000

and then either restart nginx or reconfigure it with  
worker\_rlimit\_nofile set in config.

Under Linux it should be something like:

echo 65535 \> /proc/sys/fs/file-max

(never tested).

Consult your OS docs for instructions how to make this changes  
permanent (usually you have to add them into /etc/sysctl.conf).

Maxim D.

---

<div class="post-metadata">

**Author:** ![iberci](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/a3d4f5/32.png) [@iberci](https://www.ruby-forum.com/u/iberci)\
**Post date:** [September 10, 2009, 5:39pm UTC](https://www.ruby-forum.com/t/too-many-open-files/175290/6 "2009-09-10T17:39:10Z")

</div>

heh, this is not the best way to do that

i have seen guys are puting this to the www-data .bashrc because they  
dont  
know about limits.conf

---

<div class="post-metadata">

**Author:** ![iberci](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/a3d4f5/32.png) [@iberci](https://www.ruby-forum.com/u/iberci)\
**Post date:** [September 10, 2009, 5:39pm UTC](https://www.ruby-forum.com/t/too-many-open-files/175290/7 "2009-09-10T17:39:45Z")

</div>

he has the pre process problem not the general limit i guess 🙂

---

<div class="post-metadata">

**Author:** ![iberci](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/a3d4f5/32.png) [@iberci](https://www.ruby-forum.com/u/iberci)\
**Post date:** [September 10, 2009, 5:48pm UTC](https://www.ruby-forum.com/t/too-many-open-files/175290/8 "2009-09-10T17:48:32Z")

</div>

On Thu, Sep 10, 2009 at 11:16 AM, IstvÃ¡n [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> i would start with google, look up the “how to ask smart questions”

This was totally unnecessary and rude. If you do not want to help that’s  
fine but there is no need to humiliate.

> 🙂
> 
> –  
> the sun shines for all

Jim

---

<div class="post-metadata">

**Author:** ![iberci](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/a3d4f5/32.png) [@iberci](https://www.ruby-forum.com/u/iberci)\
**Post date:** [September 10, 2009, 6:01pm UTC](https://www.ruby-forum.com/t/too-many-open-files/175290/9 "2009-09-10T18:01:25Z")

</div>

as i didn’t help this is really a huge problem

---

<div class="post-metadata">

**Author:** ![iberci](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/a3d4f5/32.png) [@iberci](https://www.ruby-forum.com/u/iberci)\
**Post date:** [September 10, 2009, 5:37pm UTC](https://www.ruby-forum.com/t/too-many-open-files/175290/10 "2009-09-10T17:37:24Z")

</div>

please note, do NOT overwrite but ADD

add to /etc/security/limits.conf

www-data soft nofile 24000  
www-data hard nofile 32000

add /etc/pam.d/login

session required /lib/security/pam\_limits.so

---

<div class="post-metadata">

**Author:** ![iberci](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/a3d4f5/32.png) [@iberci](https://www.ruby-forum.com/u/iberci)\
**Post date:** [September 10, 2009, 6:14pm UTC](https://www.ruby-forum.com/t/too-many-open-files/175290/11 "2009-09-10T18:14:18Z")

</div>

That isn’t the point and you know it. But in case you don’t I’ll make it  
simple for you. Help or don’t help but either way you don’t need to be  
an arrogant ass.

Sent from my Verizon Wireless BlackBerry

---

<div class="post-metadata">

**Author:** ![iberci](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/a3d4f5/32.png) [@iberci](https://www.ruby-forum.com/u/iberci)\
**Post date:** [September 12, 2011, 4:11pm UTC](https://www.ruby-forum.com/t/too-many-open-files/175290/12 "2011-09-12T16:11:54Z")

</div>

I found the solution for the same problem on my environment, ( Solaris  
10 ) here:

[http://www.cyberciti.biz/faq/linux-unix-nginx-too-many-open-files/](http://www.cyberciti.biz/faq/linux-unix-nginx-too-many-open-files/)

Quoting:

…

"Then open the nginx configuration file (default: /etc/nginx/nginx.conf)  
and the following line right after the “worker\_processes” entry  
line

```
worker_rlimit_nofile 20480;

```

Once both changes are made, run the Nginx lint to make sure no errors  
have been introduced:

```
# nginx -t
2010/11/01 17:07:46 [info] 9520#0: the configuration file

```

/etc/nginx/nginx.conf syntax is ok  
2010/11/01 17:07:46 [info] 9520#0: the configuration file  
/etc/nginx/nginx.conf was tested successfully

and then restart Nginx"

Thank to them I solved my problem 🙂  
hope this helps…

Posted at Nginx Forum:

> **[Re: too many open files](https://forum.nginx.org/read.php?2,6300,215117#msg-215117)**
>
> how to handle? 2009/09/10 10:09:30 \[alert\] 9691#0: accept() failed (24: Too many open files)
