Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.
2010/09/19 14:52:07 [error] 1419#0: *10220 recv() failed
(104: Connection reset by peer) while reading response header from upstream,
client: [...], server: [...], request: "POST /[...] HTTP/1.1", upstream: 
"fastcgi://unix:/server/php-fpm.sock:", host: "[...]",
referrer: "[...]"

This is the error I'm receiving randomly. 95% of the time my setup works perfectly, but once in a while I'm getting 502 for 3-4 subsequent requests.

I'm using Unix socket between the server and the PHP process as you can see, also have set up FastCGI params (SCRIPT_FILENAME), etc. correctly.

What can I do about it to strengthen the connection between these services?

Thank you very much in advance.

share|improve this question
Aside from the answers already given, check for situations where a PHP request is making another PHP request (e.g. via CURL) to the same web server. Doing so can be disastrous. –  tylerl Sep 8 '11 at 3:48

3 Answers 3

up vote 4 down vote accepted

take a look at your php5-fpm.conf, you might have reach the pm.max_children limit, which is also the amount of simultaneous requests your server can handle.

this limit can be easily reached if you have scripts that may spawn processes (beware of zombies!), or if you have long execution's time requests

share|improve this answer

You should've ran out of some system resource (e.g somaxcon, maxfiles etc)
Check your

 # netstat -s

for drops, errors and no buffers

So you can play with sysctl's (e.g. max_dgram_qlen)

share|improve this answer

I've often heard that PHP-FPM has problems with Unix sockets. Try switching to Inet sockets. Frankly, it didn't help me in the same situation, but it may help you :).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.