# Nginx timeout

**URL:** <https://www.ruby-forum.com/t/nginx-timeout/93180>\
**Category:** Deployment\
**Created:** [April 28, 2007, 8:19pm UTC](https://www.ruby-forum.com/t/nginx-timeout/93180 "2007-04-28T20:19:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b5e925/32.png) [@vince](https://www.ruby-forum.com/u/vince)\
**Post date:** [April 28, 2007, 8:19pm UTC](https://www.ruby-forum.com/t/nginx-timeout/93180/1 "2007-04-28T20:19:41Z")

</div>

I just deployed a rails app using nginx/mongrel. The app takes a file  
and then parses it, and does a bunch of stuff. It worked fine with  
straight mongrel and with straight lighttpd, but on nginx/mongrel I  
get a 504 Gateway Timeout error.

My error log shows:  
2007/04/28 23:40:48 [error] 9434#0: \*1 upstream timed out (110:  
Connection timed out) while reading response header from upstream,

Is there a setting in the nginx.conf file to avoid that? It’s  
happening with a file about 7.5MB large. Here are some relevant  
settings from my conf file (cut/paste from various parts of the conf)

Thanks in advance…

worker\_processes 6;  
worker\_rlimit\_nofile 10240;

send\_timeout 2250;  
sendfile on;  
tcp\_nopush on;

keepalive\_timeout 2250 120;  
tcp\_nodelay on;

client\_max\_body\_size 150M;

---

<div class="post-metadata">

**Author:** ![vince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b5e925/32.png) [@vince](https://www.ruby-forum.com/u/vince)\
**Post date:** [April 28, 2007, 9:06pm UTC](https://www.ruby-forum.com/t/nginx-timeout/93180/2 "2007-04-28T21:06:45Z")

</div>

On Apr 28, 2007, at 11:18 AM, Vince W wrote:

> Is there a setting in the nginx.conf file to avoid that? It’s  
> tcp\_nopush on;
> 
> keepalive\_timeout 2250 120;  
> tcp\_nodelay on;
> 
> client\_max\_body\_size 150M;

Vince-

Nginx sets proxy\_read\_timeout to 60 seconds by default. So you need  
to add a line like:

proxy\_read\_timeout 300;

Or however long you want. But it’s dangerous to have actions that  
run for so long as it ties up resources unnecessarily.

Cheers-

– Ezra Z.  
– Lead Rails Evangelist  
– removed\_email\_address@domain.invalid  
– Engine Y., Serious Rails Hosting  
– (866) 518-YARD (9273)

---

<div class="post-metadata">

**Author:** ![vince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b5e925/32.png) [@vince](https://www.ruby-forum.com/u/vince)\
**Post date:** [November 20, 2008, 12:53pm UTC](https://www.ruby-forum.com/t/nginx-timeout/93180/3 "2008-11-20T12:53:05Z")

</div>

I faced the same problem but thankfully I was able to get out of it.

In my case, I was using a javacsript to submit the form that held the  
file field. When I used a normal submit button, it all started working  
fine. 🙂 I really dont know what exactly is wrong in submitting form  
using a javascript but using the submit button instead worked.

You may want to try that…

Chirantan.

Ezra Z. wrote:

> On Apr 28, 2007, at 11:18 AM, Vince W wrote:
> 
> > Is there a setting in the nginx.conf file to avoid that? It’s  
> > tcp\_nopush on;
> > 
> > keepalive\_timeout 2250 120;  
> > tcp\_nodelay on;
> > 
> > client\_max\_body\_size 150M;
> 
> Vince-
> 
> Nginx sets proxy\_read\_timeout to 60 seconds by default. So you need  
> to add a line like:
> 
> proxy\_read\_timeout 300;
> 
> Or however long you want. But it’s dangerous to have actions that  
> run for so long as it ties up resources unnecessarily.
> 
> Cheers-
> 
> – Ezra Z.  
> – Lead Rails Evangelist  
> – removed\_email\_address@domain.invalid  
> – Engine Y., Serious Rails Hosting  
> – (866) 518-YARD (9273)
