upstream prematurely closed connection while reading response header upstream prematurely closed connection while reading response header nginx nginx

upstream prematurely closed connection while reading response header


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 --


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.