# Upload module + PHP causes active connections to continually increase

**URL:** <https://www.ruby-forum.com/t/upload-module-php-causes-active-connections-to-continually-increase/181704>\
**Category:** NGINX\
**Created:** [January 16, 2010, 9:29am UTC](https://www.ruby-forum.com/t/upload-module-php-causes-active-connections-to-continually-increase/181704 "2010-01-16T09:29:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 16, 2010, 9:29am UTC](https://www.ruby-forum.com/t/upload-module-php-causes-active-connections-to-continually-increase/181704/1 "2010-01-16T09:29:39Z")

</div>

Hi all,

I’m developing a site using the upload module v2.0.11 ( from  
[http://www.grid.net.ru/nginx/upload.en.html](http://www.grid.net.ru/nginx/upload.en.html) ) and just turned on the  
Stub Status module. I noticed that each time I send an upload form,  
the “active connections” number in the stats increments by one.

For example, if I start up Nginx and visit the status, I get:

Active connections: 1  
server accepts handled requests  
1 1 1  
Reading: 0 Writing: 1 Waiting: 0

After opening the upload form in a new tab, uploading a file, and  
getting a response from the PHP script, I get:

Active connections: 2  
server accepts handled requests  
3 3 3  
Reading: 0 Writing: 2 Waiting: 0

After uploading another file, I get:

Active connections: 3  
server accepts handled requests  
4 4 5  
Reading: 0 Writing: 3 Waiting: 0

I’m concerned that the “active connections” number keeps increasing  
(as well as the “writing” number), and never seems to go down. Does  
this mean that Nginx is holding extra connections (and possibly extra  
file descriptors) open? I’m wondering if this will be a problem once I  
deploy the site and the server is running for long periods of time.  
Could it reach some system maximum of open file descriptors?

I thought it might be a problem with my fastcgi setup, but the active  
connections number doesn’t increase when I visit regular (non-upload)  
PHP pages. Also, the problem didn’t occur when I set @accept (in  
config below) to redirect to a .txt file instead of a .php file. In  
that case, the file appears in the upload directory, but I get a 405  
error because Nginx rejects POSTs to static files.

The relevant section of my nginx.conf is:

location /accept {  
upload\_pass @accept;  
upload\_store /var/www/fbp/uploads/files;  
upload\_set\_form\_field “$upload\_field\_name[name]” “$upload\_file\_name”;  
upload\_set\_form\_field “$upload\_field\_name[content\_type]”  
“$upload\_content\_type”;  
upload\_set\_form\_field “$upload\_field\_name[tmp\_file]”  
“$upload\_tmp\_path”;  
upload\_aggregate\_form\_field “$upload\_field\_name[size]”  
“$upload\_file\_size”;  
upload\_pass\_form\_field “key”;  
}

location @accept {  
rewrite ^(.\*)$ /accept.php last;  
}

location ~ .php$ {  
fastcgi\_pass 127.0.0.1:9000;  
fastcgi\_index index.php;  
fastcgi\_param SCRIPT\_FILENAME $document\_root$fastcgi\_script\_name;  
include fastcgi\_params;  
}

My accept.php is simply:

\<?php die('accept.php'); ?\>

After the upload, the files appear in the uploads/files directory, and  
the text ‘accept.php’ is properly returned to the browser.

Does anyone know what could cause this, and whether I should be  
concerned? Any help would be appreciated!

Thanks!  
Alan

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 16, 2010, 11:07am UTC](https://www.ruby-forum.com/t/upload-module-php-causes-active-connections-to-continually-increase/181704/2 "2010-01-16T11:07:25Z")

</div>

Support wrote:

> server accepts handled requests
> 
> file descriptors) open? I’m wondering if this will be a problem once I  
> The relevant section of my nginx.conf is:  
> }  
> }  
> concerned? Any help would be appreciated!  
> Using this patch or switching off keepalive might solve the problem.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 18, 2010, 9:25pm UTC](https://www.ruby-forum.com/t/upload-module-php-causes-active-connections-to-continually-increase/181704/3 "2010-02-18T21:25:15Z")

</div>

Seeing the same problem here. Same version of upload, nginx is 0.8.33.  
Open file descriptors are not being closed after upstreaming to fastcgi.  
Have a link to that patch? I’ll be happy to test it out. 🙂

Posted at Nginx Forum:

> **[Re: Upload module + PHP causes active connections to continually increase](https://forum.nginx.org/read.php?2,41943,55376#msg-55376)**
>
> Hi all, I'm developing a site using the upload module v2.0.11 ( from http://www.grid.net.ru/nginx/upload.en.html ) and just turned on the Stub Status module. I noticed that each time I send an upload form, the "active connections" number in...

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 19, 2010, 10:02am UTC](https://www.ruby-forum.com/t/upload-module-php-causes-active-connections-to-continually-increase/181704/4 "2010-02-19T10:02:38Z")

</div>

icqheretic wrote:

> Seeing the same problem here. Same version of upload, nginx is 0.8.33. Open file descriptors are not being closed after upstreaming to fastcgi. Have a link to that patch? I’ll be happy to test it out. 🙂

May be this can help.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 23, 2010, 12:22pm UTC](https://www.ruby-forum.com/t/upload-module-php-causes-active-connections-to-continually-increase/181704/5 "2010-02-23T12:22:08Z")

</div>

Excellent – the patch works great for me.

On Fri, Feb 19, 2010 at 2:39 PM, Matthieu T.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 23, 2010, 9:17pm UTC](https://www.ruby-forum.com/t/upload-module-php-causes-active-connections-to-continually-increase/181704/6 "2010-02-23T21:17:45Z")

</div>

Thanks, Valery. Patch fixed our problem.

Posted at Nginx Forum:

> **[Re: Upload module + PHP causes active connections to continually increase](https://forum.nginx.org/read.php?2,41943,56516#msg-56516)**
>
> Hi all, I'm developing a site using the upload module v2.0.11 ( from http://www.grid.net.ru/nginx/upload.en.html ) and just turned on the Stub Status module. I noticed that each time I send an upload form, the "active connections" number in...
