Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

upstream prematurely closed connection while reading response header

I am trying to deploy a Flask Python app on dotcloud (which uses nginx) and MongoDB, and at one point am routing to Twitter for OAuth authorization. Upon trying to route back to my app I get the nginx error described in the title, and have no idea why. Any suggestions? It works perfectly fine in development mode with localhost

like image 851
Ashu Goel Avatar asked Dec 08 '22 22:12

Ashu Goel


2 Answers

Take a look at your uWSGI logs which for me were in /var/log/uwsgi.

I encountered this problem when not having a plugin installed. In my case # apt-get install uwsgi-plugin-python did the trick, because I was trying to execute a python script.

Not having this plugin yielded a 502 from nginx, and in my uWSGI logs I saw:

-- unavailable modifier requested: 0 --

like image 120
Dmitry Minkovsky Avatar answered Apr 28 '23 00:04

Dmitry Minkovsky


That error usually happens when your upstream server timeouts out (takes too long) Are you seeing anything in your application logs (/var/log/supervisor/) when this happens? Also how long are the requests taking.

I have seen a problem where the uWSGI server is connecting to an external source and the external source is taking a long time to respond, which causes the uWSGI request to take a long time, and thus nginx gives up.

Another thing to look for is to see if your process is running out of memory and is getting killed, which could also cause this sort of error.

like image 44
Ken Cochrane Avatar answered Apr 28 '23 02:04

Ken Cochrane