Error Nginx 502 [upstream prematurely closed connection]

javdev nginx-forum at
Sun Oct 11 21:42:37 UTC 2015

Hello guys this is my first question here.

I'm working on nginx almost 2 years, but in the laste days I have founded an
error, very complicated to solve.

I'm working on Amazon stack, with Elastic Load Balancer (Using TCP (SSL)),
then the request is sent to Nginx (1.8.0), 2 EC2 Instances, each instance
has a Sails project (running on 1337 port).

The connectio is amolst fine, actually sometimes works fine, but after 3 or
5 refresh page, throw the next 502 error:

--- code error ----
2015/10/11 20:14:46 [error] 4623#0: *38 upstream prematurely closed
connection while reading response header from upstream, client:, server: , request: "GET
HTTP/1.1", upstream:
host: ""
----- End code error----

My configurarion is here:

And my hostvirtual is here:

I have tried a lot of suggestions but anything works after 1 week.

Please someone can help me?

Posted at Nginx Forum:,262108,262108#msg-262108

More information about the nginx mailing list