# Upstream Prematurely Closed Connection

**URL:** <https://www.ruby-forum.com/t/upstream-prematurely-closed-connection/186964>\
**Category:** NGINX\
**Created:** [April 15, 2010, 12:51am UTC](https://www.ruby-forum.com/t/upstream-prematurely-closed-connection/186964 "2010-04-15T00:51:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![APseudoUtopia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/d26b3c/32.png) [@APseudoUtopia](https://www.ruby-forum.com/u/APseudoUtopia)\
**Post date:** [April 15, 2010, 12:51am UTC](https://www.ruby-forum.com/t/upstream-prematurely-closed-connection/186964/1 "2010-04-15T00:51:54Z")

</div>

I recently upgraded PHP from 5.2.9 to 5.3.2. Ever since then, nginx  
hasn’t been working properly. BUT, I can tell that it is not php’s  
fault because another domain is working perfectly (using the same  
nginx instance).

nginx version: nginx/0.7.65

[admin.mysite.com](http://admin.mysite.com) works perfectly. I have some PHP scripts on that  
subdomain, and they work perfectly.

However, [mysite.com](http://mysite.com) gives a 502 HTTP error. The error logs in nginx  
give:

2010/04/14 21:57:54 [error] 93347#0: \*35 upstream prematurely closed  
connection while reading response header from upstream, client:  
96.x.x.x, server: [mysite.com](http://mysite.com), request: “GET / HTTP/1.1”, upstream:  
“fastcgi://127.0.0.1:9000”, host: “[mysite.com](http://mysite.com)”

nginx is serving other non-php files perfectly fine (for example,  
images and javascript). But all php files give the 502 error.

The php-cgi processes are started using spawn-fcgi. I have 20 child  
processes set to run. I have monitored them throughout many requests  
and none of them seem to be dying - they all exist after the 502  
errors.

Here’s my entire nginx.conf. There are a couple servers: the admin  
site, a couple ssl/www redirects, then the main site. PHP on the admin  
site works fine, but PHP on the main site does not work as mentioned  
above.  
[http://pastie.org/private/hwi3niwgyynmcpvlgkuuxg](http://pastie.org/private/hwi3niwgyynmcpvlgkuuxg)

Here’s the fastcgi\_params include:  
[http://pastie.org/private/edbmxdtqkazapisegq6ua](http://pastie.org/private/edbmxdtqkazapisegq6ua)

Does anyone know why this is happening?

Thank you.
