# Form input limit reached?

**URL:** <https://www.ruby-forum.com/t/form-input-limit-reached/106441>\
**Category:** Rails\
**Created:** [June 10, 2007, 4:51pm UTC](https://www.ruby-forum.com/t/form-input-limit-reached/106441 "2007-06-10T16:51:53Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![blakeage](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/b38774/32.png) [@blakeage](https://www.ruby-forum.com/u/blakeage)\
**Post date:** [June 10, 2007, 4:51pm UTC](https://www.ruby-forum.com/t/form-input-limit-reached/106441/1 "2007-06-10T16:51:53Z")

</div>

I have a form that uploads 2 files via 2 file fields (I’m not actually  
uploading anything, but this problem occurs specifically when the form  
enctype is multipart). If I remove the multipart designation from the  
form, the data in the form is saved. Otherwise, I get the following  
error:

Sun Jun 10 10:46:34 -0400 2007: Error calling Dispatcher.dispatch  
#\<Errno::EMFILE: Too many open files - /tmp/CGI.6962.248\>

The form has several inputs (text fields and select fields  
only)…approximately 350 (on various divs that are toggled via  
javascript). If I remove several of the form inputs (say, half), I  
don’t get the too many open files error.

Is there a limit to the number of fields the cgi can handle? This  
happens in Mongrel and Webrick.

I have another form (same action, different data type) that is almost  
identical in nature to this form that posts successfully; however, the  
number of form inputs is about 250.

Ideas?

---

<div class="post-metadata">

**Author:** ![blakeage](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/b38774/32.png) [@blakeage](https://www.ruby-forum.com/u/blakeage)\
**Post date:** [June 11, 2007, 5:51pm UTC](https://www.ruby-forum.com/t/form-input-limit-reached/106441/2 "2007-06-11T17:51:16Z")

</div>

> Sun Jun 10 10:46:34 -0400 2007: Error calling Dispatcher.dispatch  
> #\<Errno::EMFILE: Too many open files - /tmp/CGI.6962.248\>

That looks like a system error. Ie, the OS is reporting that the user  
running the rails app is trying to open a file when the per-user limit  
for open files has been reached.

What’s the OS?

steve

---

<div class="post-metadata">

**Author:** ![blakeage](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/b38774/32.png) [@blakeage](https://www.ruby-forum.com/u/blakeage)\
**Post date:** [June 11, 2007, 9:06pm UTC](https://www.ruby-forum.com/t/form-input-limit-reached/106441/3 "2007-06-11T21:06:42Z")

</div>

Steve R. wrote:

> That looks like a system error. Ie, the OS is reporting that the user  
> running the rails app is trying to open a file when the per-user limit  
> for open files has been reached.
> 
> What’s the OS?  
> OS X - I don’t understand why removing select fields would change the  
> behavior (cause the error to cease). But who knows, maybe the cgi  
> creates a temp file for every form input or something. There are only  
> two file field inputs, and even if I comment them out (but keep the form  
> as multipart), I still get the error.

---

<div class="post-metadata">

**Author:** ![blakeage](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/b38774/32.png) [@blakeage](https://www.ruby-forum.com/u/blakeage)\
**Post date:** [June 11, 2007, 10:06pm UTC](https://www.ruby-forum.com/t/form-input-limit-reached/106441/4 "2007-06-11T22:06:00Z")

</div>

As a test, type the following at a Darwin shell:

ulimit -n  
[reports the number of allowed open files]

ulimit -n unlimited  
[raises the limit ot the max allowed]

ulimit -n  
[confirms the limit has been raised]

script/server

Then use the form and see if the problem goes away.

steve

---

<div class="post-metadata">

**Author:** ![blakeage](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/b38774/32.png) [@blakeage](https://www.ruby-forum.com/u/blakeage)\
**Post date:** [June 12, 2007, 5:10pm UTC](https://www.ruby-forum.com/t/form-input-limit-reached/106441/5 "2007-06-12T17:10:38Z")

</div>

Blake M. wrote:

> Thanks, “ulimit -n 1024” fixed the problem. It was set to 256.

That still means your app is opening more than 256 files which unless  
you’re doing something really odd is not good. You can use ‘lsof’ to see  
what’s open.

steve

---

<div class="post-metadata">

**Author:** ![blakeage](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/b38774/32.png) [@blakeage](https://www.ruby-forum.com/u/blakeage)\
**Post date:** [June 12, 2007, 4:02pm UTC](https://www.ruby-forum.com/t/form-input-limit-reached/106441/6 "2007-06-12T16:02:03Z")

</div>

Thanks, “ulimit -n 1024” fixed the problem. It was set to 256.
