# Nginx temp file being deleted errenously

**URL:** <https://www.ruby-forum.com/t/nginx-temp-file-being-deleted-errenously/229810>\
**Category:** NGINX\
**Created:** [January 26, 2013, 1:36am UTC](https://www.ruby-forum.com/t/nginx-temp-file-being-deleted-errenously/229810 "2013-01-26T01:36:23Z")\
**Posts on this page:** 2\
**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 26, 2013, 1:36am UTC](https://www.ruby-forum.com/t/nginx-temp-file-being-deleted-errenously/229810/1 "2013-01-26T01:36:23Z")

</div>

Hello everyone,

My company processes millions of requests for file uploads/downloads and  
we  
are looking at Nginx to replace Apache. We are running into a problem  
that  
I hope you can help – I have searched the web and even read Nginx HTTP  
Server book by Clement Nedelcu.

At a high level, the flow of a request through our system is as follows:  
user agent posts the data to upload → Ngixn acting as a reverse  
proxy  
 → Object store → post action of passing request to Uwsgi.

Problem: when uploading a large file (~ 100MB) , the post action is  
failing. The error message seen in error.log is “8 sendfile() failed  
(9:  
Bad file descriptor) while sending request to upstream,” message. This  
use  
case occurs even if no load on the system,

When I enable “debug”, I see that after the Nginx streams the bytes to  
the  
object store, the temp file is deleted. When the post action is  
executed it  
fails as the temp file is gone.

\*Note: this error is NOT seen when upload small files.

Details:

- Nginx version 1.1.17

- UWsgi vesrion 1.0

- Cent OS 2.6.32-131.0.15.el6.x86\_64

- The relevant nginx configuration is:

Any help would be great. I really want to use Nginx but this is now a  
blocker issue for my company.

Regards

Posted at Nginx Forum:

> **[Nginx temp file being deleted errenously](https://forum.nginx.org/read.php?2,235586,235586#msg-235586)**
>
> Hello everyone, My company processes millions of requests for file uploads/downloads and we are looking at Nginx to replace Apache. We are running into a problem that I hope you can help -- I have searched the web and even read Nginx HTTP Server book...

---

<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 30, 2013, 2:26pm UTC](https://www.ruby-forum.com/t/nginx-temp-file-being-deleted-errenously/229810/2 "2013-01-30T14:26:43Z")

</div>

On 01/26/2013 02:36 AM, [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> \*Note: this error is NOT seen when upload small files.  
> I would store the file in some temporary space on frontend, and then  
> forwarded it to the storage backend.

–  
With best regards,  
Gregory E.
