Forum: NGINX "502 Bad Gateway" on first request in a setup with Apache 2.4-servers as upstreams

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
De7b680154f831d87d8ea48743852f14?d=identicon&s=25 maltris (Guest)
on 2016-07-15 19:22
(Received via mailing list)
The error I am getting in the logs:

"upstream prematurely closed connection while reading response header

After the first request it works for 10-15 seconds without any problem.
According to tcpdump in the first request (the failing one) the upstream
receiving one GET and nothing more.

I found one workaround
which is adding the same upstream twice and adding the "backup"-option.
first request then fails but the second in all of my cases succeeds
via logs and tcpdump).

Any ideas (also some comments that could lead me to the solution would

Posted at Nginx Forum:,268306,268306#msg-268306
This topic is locked and can not be replied to.