# Timeout with UWSGI?

**URL:** <https://www.ruby-forum.com/t/timeout-with-uwsgi/244599>\
**Category:** NGINX\
**Created:** [May 10, 2016, 9:30pm UTC](https://www.ruby-forum.com/t/timeout-with-uwsgi/244599 "2016-05-10T21:30:50Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sadaf\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/858c86/32.png) [@Sadaf\_N](https://www.ruby-forum.com/u/Sadaf_N)\
**Post date:** [May 10, 2016, 9:30pm UTC](https://www.ruby-forum.com/t/timeout-with-uwsgi/244599/1 "2016-05-10T21:30:50Z")

</div>

Hi all,  
My Flask app is finally up and running, using UWSGI! This is great, but  
I’m  
hitting a problem if the app takes too long. It talks to an AS400, so  
can  
sometimes take a while to gather the requested information, parse it,  
and  
hand back JSON. Sometimes, by the time it does this, Nginx has given up  
on  
it, so I see an IOError reported in the log because of a broken pipe.  
I’m  
wondering how I can increase the timeout limit, to make Nginx wait  
longer  
before closing this connection? Thanks!

---

<div class="post-metadata">

**Author:** ![redroot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/919ad9/32.png) [@redroot](https://www.ruby-forum.com/u/redroot)\
**Post date:** [May 10, 2016, 10:31pm UTC](https://www.ruby-forum.com/t/timeout-with-uwsgi/244599/2 "2016-05-10T22:31:00Z")

</div>

On Tue, May 10, 2016 at 03:29:24PM -0400, Alex H. wrote:

Hi there,

> Sometimes, by the time it does this, Nginx has given up on  
> it, so I see an IOError reported in the log because of a broken pipe. I’m  
> wondering how I can increase the timeout limit, to make Nginx wait longer  
> before closing this connection? Thanks!

What directive do you use to tell nginx to talk to the upstream service?

Put that directive after “[http://nginx.org/r/](http://nginx.org/r/)”, and visit that url. That  
should bring you to the documentation for that directive.

Go to the top of the page; there is a list of all of the other  
directives  
that that module provides.

Probably you care about the “read timeout” directive: you can invite  
nginx  
to wait longer between successive successful read operations; or you can  
configure your upstream service to write something more frequently that  
it currently does.

Good luck with it,

## f

Francis D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![redroot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/919ad9/32.png) [@redroot](https://www.ruby-forum.com/u/redroot)\
**Post date:** [May 11, 2016, 9:24am UTC](https://www.ruby-forum.com/t/timeout-with-uwsgi/244599/3 "2016-05-11T09:24:40Z")

</div>

On Tue, May 10, 2016 at 05:09:21PM -0400, Alex H. wrote:

Hi there,

> We may be finding the problem… I’m not sure what you mean by ‘upstream  
> service’.

Somehow, you tell nginx to talk to “the next server”. It can be with  
“proxy\_pass” or “fastcgi\_pass” or, most likely here, “uwsgi\_pass”.

“the next server” is the upstream, in this context.

And the directive is whichever \*\_pass you use here.

Cheers,

## f

Francis D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![redroot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/919ad9/32.png) [@redroot](https://www.ruby-forum.com/u/redroot)\
**Post date:** [May 10, 2016, 11:10pm UTC](https://www.ruby-forum.com/t/timeout-with-uwsgi/244599/4 "2016-05-10T23:10:44Z")

</div>

We may be finding the problem… I’m not sure what you mean by ‘upstream  
service’. I know I have an upstream context for PHP, which defines the  
socket file to use, but I don’t have that for UWSGI. The sample  
configurations I found never said to include one, and I don’t have a  
deep  
enough grasp of how all this works to know what to put in one for UWSGI.  
I’ll certainly start looking this up, though.

---

<div class="post-metadata">

**Author:** ![redroot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/919ad9/32.png) [@redroot](https://www.ruby-forum.com/u/redroot)\
**Post date:** [May 11, 2016, 3:55pm UTC](https://www.ruby-forum.com/t/timeout-with-uwsgi/244599/5 "2016-05-11T15:55:29Z")

</div>

Hi Alex,

Am 11-05-2016 09:24, schrieb Francis D.:

> “the next server” is the upstream, in this context.
> 
> And the directive is whichever \*\_pass you use here.

What Francis could mean could be this.

> **[Module ngx\_http\_upstream\_module](http://nginx.org/en/docs/http/ngx_http_upstream_module.html)**

Some basic concept.

> **[Using nginx as HTTP load balancer](http://nginx.org/en/docs/http/load_balancing.html)**

Maybe you should increase some timeouts in uwsgi

> **[Module ngx\_http\_uwsgi\_module](http://nginx.org/en/docs/http/ngx_http_uwsgi_module.html)**

→ search for timeout.

There are some info’s in the net 😉

[https://startpage.com/do/search?cmd=process\_search&query=nginx+long+running+backend+requests&cat=web&with\_language=&with\_region=&pl=&ff=&rl=&hmb=1&with\_date=y&abp=-1](https://startpage.com/do/search?cmd=process_search&query=nginx+long+running+backend+requests&cat=web&with_language=&with_region=&pl=&ff=&rl=&hmb=1&with_date=y&abp=-1)

Can you please add the output of

nginx -V

to your answer and the relevant config.

Hth & Best regards  
aleks

---

<div class="post-metadata">

**Author:** ![redroot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/919ad9/32.png) [@redroot](https://www.ruby-forum.com/u/redroot)\
**Post date:** [May 11, 2016, 4:02pm UTC](https://www.ruby-forum.com/t/timeout-with-uwsgi/244599/6 "2016-05-11T16:02:30Z")

</div>

Yes, I’m using uwsgi\_pass:

uwsgi\_pass 127.0.0.1:9876;

---

<div class="post-metadata">

**Author:** ![redroot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/919ad9/32.png) [@redroot](https://www.ruby-forum.com/u/redroot)\
**Post date:** [May 11, 2016, 4:23pm UTC](https://www.ruby-forum.com/t/timeout-with-uwsgi/244599/7 "2016-05-11T16:23:31Z")

</div>

Hi Alex.

Am 11-05-2016 16:01, schrieb Alex H.:

> Yes, I’m using uwsgi\_pass:
> 
> uwsgi\_pass 127.0.0.1:9876 [1];

Hm. I think you have send the mail to early 😉  
Please can you read again my mail and add some more lines to your  
answer, thank you.

Best regards  
aleks

---

<div class="post-metadata">

**Author:** ![redroot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/919ad9/32.png) [@redroot](https://www.ruby-forum.com/u/redroot)\
**Post date:** [May 11, 2016, 4:35pm UTC](https://www.ruby-forum.com/t/timeout-with-uwsgi/244599/8 "2016-05-11T16:35:48Z")

</div>

Ineeed. Sorry about that. The problem is that I can’t capture the output  
of  
nginx -V, as–for some reason–the \> symbol is only producing an empty  
file. I can’t copy and paste directly from or to the prompt either. If  
you  
tell me what you’re looking for in nginx -V, I can tell you that value,  
but  
there’s a lot of information there.

My site configuration file is:

server {  
include restrictions/localOnly;  
listen 80;  
server\_tokens off;  
server\_name [myapp.mysite.com](http://myapp.mysite.com);  
location / {  
include uwsgi\_params;  
uwsgi\_pass 127.0.0.1:9876;  
}

location /static {  
alias /var/www/myapp/app/static;  
}

}

---

<div class="post-metadata">

**Author:** ![redroot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/919ad9/32.png) [@redroot](https://www.ruby-forum.com/u/redroot)\
**Post date:** [May 11, 2016, 4:45pm UTC](https://www.ruby-forum.com/t/timeout-with-uwsgi/244599/9 "2016-05-11T16:45:09Z")

</div>

Hi Alex,

nginx -V uses stderr, so try:

nginx -V 2\>/tmp/out.txt

This will redirect stderr to the file instead of stdout.

Kind Regards  
Andrew

On 11/05/16 15:34, Alex H. wrote:

> listen 80;
> 
> ```
> Hi there,
> 
> ```
> 
> 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)

–  
Andrew H. (LinuxJedi)  
Technical Product Manager, NGINX Inc.

---

<div class="post-metadata">

**Author:** ![redroot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/919ad9/32.png) [@redroot](https://www.ruby-forum.com/u/redroot)\
**Post date:** [May 11, 2016, 4:48pm UTC](https://www.ruby-forum.com/t/timeout-with-uwsgi/244599/10 "2016-05-11T16:48:39Z")

</div>

Ah, that explains it. Thanks.

nginx -V  
nginx version: nginx/1.6.2  
TLS SNI support enabled  
configure arguments: --with-cc-opt=‘-g -O2 -fstack-protector-strong  
-Wformat -Werror=format-security -D\_FORTIFY\_SOURCE=2’  
–with-ld-opt=-Wl,-z,relro --prefix=/usr/share/nginx  
–conf-path=/etc/nginx/nginx.conf  
–http-log-path=/var/log/nginx/access.log  
–error-log-path=/var/log/nginx/error.log  
–lock-path=/var/lock/nginx.lock  
–pid-path=/run/nginx.pid  
–http-client-body-temp-path=/var/lib/nginx/body  
–http-fastcgi-temp-path=/var/lib/nginx/fastcgi  
–http-proxy-temp-path=/var/lib/nginx/proxy  
–http-scgi-temp-path=/var/lib/nginx/scgi  
–http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit  
–with-ipv6 --with-http\_ssl\_module --with-http\_stub\_status\_module  
–with-http\_realip\_module --with-http\_auth\_request\_module  
–with-http\_addition\_module --with-http\_dav\_module  
–with-http\_geoip\_module  
–with-http\_gzip\_static\_module --with-http\_image\_filter\_module  
–with-http\_spdy\_module --with-http\_sub\_module --with-http\_xslt\_module  
–with-mail --with-mail\_ssl\_module  
–add-module=/build/nginx-T5fW9e/nginx-1.6.2/debian/modules/nginx-auth-pam  
–add-module=/build/nginx-T5fW9e/nginx-1.6.2/debian/modules/nginx-dav-ext-module  
–add-module=/build/nginx-T5fW9e/nginx-1.6.2/debian/modules/nginx-echo  
–add-module=/build/nginx-T5fW9e/nginx-1.6.2/debian/modules/nginx-upstream-fair  
–add-module=/build/nginx-T5fW9e/nginx-1.6.2/debian/modules/ngx\_http\_substitutions\_filter\_module

On Wed, May 11, 2016 at 10:44 AM, Andrew H.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
