# Upload file problem (500 Internal Server Error)

**URL:** <https://www.ruby-forum.com/t/upload-file-problem-500-internal-server-error/211322>\
**Category:** NGINX\
**Created:** [September 1, 2011, 10:43am UTC](https://www.ruby-forum.com/t/upload-file-problem-500-internal-server-error/211322 "2011-09-01T10:43:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [September 1, 2011, 10:43am UTC](https://www.ruby-forum.com/t/upload-file-problem-500-internal-server-error/211322/1 "2011-09-01T10:43:39Z")

</div>

HI,

I’m using version: ‘nginx version: nginx/1.1.0’

While uploading file I’m getting an error: ‘500 Internal Server Error’

This is an nginx.log result:

* * *

## 2011/09/01 10:39:49 [alert] 28764#0: accept() failed (24: Too many open files) 2011/09/01 10:39:49 [alert] 28764#0: accept() failed (24: Too many open files) 2011/09/01 10:39:49 [alert] 28764#0: accept() failed (24: Too many open files) 2011/09/01 10:39:49 [alert] 28764#0: accept() failed (24: Too many open files) 2011/09/01 10:39:49 [alert] 28764#0: \*13013 socket() failed (24: Too many open files) while connecting to upstream, client: 127.0.0.1, server: 192.168.0.222, request: “POST /upload HTTP/1.0”, upstream: “[http://127.0.0.1:80/upload](http://127.0.0.1:80/upload)”, host: “localhost”, referrer: “[http://192.168.0.222/CRM/upload4.html](http://192.168.0.222/CRM/upload4.html)” 2011/09/01 10:39:49 [crit] 28764#0: \*13013 open() “/var/www/50x.html” failed (24: Too many open files), client: 127.0.0.1, server: 192.168.0.222, request: “POST /upload HTTP/1.0”, upstream: “[http://127.0.0.1:80/upload](http://127.0.0.1:80/upload)”, host: “localhost”, referrer: “[http://192.168.0.222/CRM/upload4.html](http://192.168.0.222/CRM/upload4.html)”

The ‘lsof -n | wc -l’ command gives a result: ‘1980’ value.  
The ‘cat /proc/sys/fs/file-max’ command gives a result: ‘203296’.

So it is not a too many open files problem?

## The upload4.html containt:
Test upload
## Select files to upload
  
-----

Please help 😉

–  
best regards  
Piotr P.

---

<div class="post-metadata">

**Author:** ![ppalka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/aeb1de/32.png) [@ppalka](https://www.ruby-forum.com/u/ppalka)\
**Post date:** [September 1, 2011, 11:52am UTC](https://www.ruby-forum.com/t/upload-file-problem-500-internal-server-error/211322/2 "2011-09-01T11:52:18Z")

</div>

try this?

> worker\_rlimit\_nofile 10000;

---

<div class="post-metadata">

**Author:** ![ppalka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/aeb1de/32.png) [@ppalka](https://www.ruby-forum.com/u/ppalka)\
**Post date:** [September 1, 2011, 12:03pm UTC](https://www.ruby-forum.com/t/upload-file-problem-500-internal-server-error/211322/3 "2011-09-01T12:03:25Z")

</div>

On Thu, 1 Sep 2011 17:49:29 +0800, li zJay wrote:

> try this?
> 
> > worker\_rlimit\_nofile 10000;

HI,

Thank you, The ‘worker\_rlimit\_nofile 10000’ is not solving the problem.

I have added a ‘fastcgi\_pass 127.0.0.1:9000’ to a ‘/upload’ location  
and now I’m getting the ‘No input file specified.’ error on html form  
and the ‘/var/log/nginx/error.log’ is clear.

This is my ‘/upload’ configuration:

* * *

location /upload {  
#Pass altered request body to this location  
upload\_pass @test;

#Store files to this directory  
#The directory is hashed, subdirectories 0 1 2 3 4 5 6 7 8 9 should  
exist  
upload\_store /var/www/upload;

#Allow uploaded files to be read only by user  
#upload\_store\_access user:r;  
upload\_store\_access user:rw group:rw all:r;

#Set specified fields in request body  
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.path “$upload\_tmp\_path”;

#Inform backend about hash and size of a file  
upload\_aggregate\_form\_field “$upload\_field\_name.md5”  
“$upload\_file\_md5”;  
upload\_aggregate\_form\_field “$upload\_field\_name.size”  
“$upload\_file\_size”;

upload\_pass\_form\_field “^submit$|^description$”;

upload\_cleanup 400 404 499 500-505;

fastcgi\_pass 127.0.0.1:9000;  
}

# Pass altered request body to a backend

location @test {  
proxy\_pass [http://localhost:80](http://localhost:80);  
}

---

<div class="post-metadata">

**Author:** ![ppalka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/aeb1de/32.png) [@ppalka](https://www.ruby-forum.com/u/ppalka)\
**Post date:** [September 2, 2011, 1:18am UTC](https://www.ruby-forum.com/t/upload-file-problem-500-internal-server-error/211322/4 "2011-09-02T01:18:09Z")

</div>

you can try to add such line to /etc/security/limits.conf  
nginx soft nofile 131072  
nginx hard nofile 1048576

## and fastcgi\_pass to run PHP you need to set SCRIPT\_FILENAME, you may first include fastcgi\_params at /etc/nginx (if you install nginx with binary), and then add such line before fastcgi\_pass: fastcgi\_param SCRIPT\_FILENAME $document\_root$fastcgi\_script\_name; Piotr P. Wrote:

> I have added a ‘fastcgi\_pass 127.0.0.1:9000’ to a  
> upload\_pass @test;
> 
> upload\_aggregate\_form\_field  
> fastcgi\_pass 127.0.0.1:9000;  
> Piotr P.
> 
> * * *
> 
> nginx mailing list  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [mailman.nginx.org archive](http://mailman.nginx.org/mailman/listinfo/nginx)

Posted at Nginx Forum:  
[http://forum.nginx.org/read.php?2,214612,214639#msg-214639](http://forum.nginx.org/read.php?2,214612,214639#msg-214639)

---

<div class="post-metadata">

**Author:** ![ppalka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/aeb1de/32.png) [@ppalka](https://www.ruby-forum.com/u/ppalka)\
**Post date:** [September 5, 2011, 8:29am UTC](https://www.ruby-forum.com/t/upload-file-problem-500-internal-server-error/211322/5 "2011-09-05T08:29:19Z")

</div>

On Thu, 01 Sep 2011 19:17:06 -0400, magicbear wrote:

> $document\_root$fastcgi\_script\_name;  
> HI,

Thanks, this is also not solving the problem. I will start from the  
beginning in new thread.

–  
best regards  
Piotr P.

* * *

POLOK WELDING  
44-121 Gliwice  
ul. Sowińskiego 3  
NIP: 631-112-45-46

tel: (32) 725 77 77  
fax: (32) 444 64 50

> **[Regeneracja silników, głowic i bloków — Gliwice | POLOK Sp. z o.o.](https://polok.pl/)**
>
> POLOK Gliwice od 1989 roku. Regeneracja głowic i części silnikowych dla klientów z województw śląskiego i opolskiego. Bezpłatny odbiór, dostawa 29 zł brutto.
