I am making flask app which is binded gunicorn .As i open my page i get 502 Bad gatway error and tail has given this error log - *120 upstream prematurely closed connection while reading response header from upstream.What to do??
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
A 502 error could be caused by a number of things, and without more information about how you’ve configured your application it is hard to get to the root of your specific issue. The tutorial “How To Troubleshoot Common HTTP Error Codes” gives you a good place to start debugging your problem:
The additional context (
upstream prematurely closed connection
) suggests that this might be caused by Gunicorn timing-out before successfully responding to the request. By default, Gunicorn is set to time out after 30 seconds. Raising that value might help debug the issue. This can be done by passing--timeout
when starting it. See the Gunicorn docs for more info.For more information about getting a Flask app up and running with Gunicorn and Nginx, check out: