Sydcpt
Sydcpt

Reputation: 139

Python Nginx Production Timeout

I have built a quick bottle app which calls an external API and updates a few fields. When I run this app on my dev machine it runs for about 3 minutes as the API which it is talking to is rather slow.

When I move the app into our production environment, I am getting a 502 response. It bombs out exactly 30 seconds after starting. I beleive this is a timeout.

I followed this guide to setup the environment: https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-uwsgi-and-nginx-on-ubuntu-14-04

Anyone have an idea how to increase the timeout on NGinx? I have tried using setting up the proxy_connect_timeout is the NGinx conf file, but it does nothing to resolve the issue:

proxy_connect_timeout   300;
proxy_send_timeout      300;
proxy_read_timeout      300;

Any help would be greatly appreciated.

Upvotes: 2

Views: 1251

Answers (1)

Piyush S. Wanare
Piyush S. Wanare

Reputation: 4933

You could try upgrading the timeout for your proxy pass in Nginx by adding:

proxy_connect_timeout 75s;
proxy_read_timeout 300s;

on /etc/nginx/sites-available/default or /etc/nginx/nginx.conf if you want to increase the timeout limit on all sites served by nginx.

You must add --timeout 300 as well to your gunicorn process/config.

This solved my problems in the past with bigger uploads.

Upvotes: 2

Related Questions