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??
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
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.
Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.
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: