Nginx + php-fpm "504 Gateway Time-out" error with almost zero load (on a test-server)

Jérôme Loyet jerome at
Wed Sep 8 13:54:39 MSD 2010

2010/9/8 minaev <nginx-forum at>:
> Rahul,
> I have the same problem and I think I, probably, know what's causing it.
> The bad thing is that I got it trying to solve another one and I don't
> know how to fix both :)
> So, until today, my server sometimes issued 504 error. The error log
> reported "upstream timed out (110: Connection timed out) while reading
> response header from upstream" error. Trying to fix it, I played with
> various PHP-FPM timeouts. So, I increased pm.max_children from 5 to 10
> and set request_terminate_timeout to 30s. Immediately after these
> changes had been  made, 504 error was gone, but now I receive 502 with
> the same diagnostics as yours: "Connection reset by peer".
> Do you have request_terminate_timeout defined in your php-fpm.conf?

you have too many connections and FPM is not able to handle
everything. You can play with backlog, max_client and timeouts.

> Posted at Nginx Forum:,127854,128331#msg-128331
> _______________________________________________
> nginx mailing list
> nginx at

More information about the nginx mailing list