# I got 502 and error\_log print upstream sent invalid status "0"

**URL:** <https://www.ruby-forum.com/t/i-got-502-and-error-log-print-upstream-sent-invalid-status-0/218390>\
**Category:** NGINX\
**Created:** [March 30, 2012, 5:15am UTC](https://www.ruby-forum.com/t/i-got-502-and-error-log-print-upstream-sent-invalid-status-0/218390 "2012-03-30T05:15:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [March 30, 2012, 5:15am UTC](https://www.ruby-forum.com/t/i-got-502-and-error-log-print-upstream-sent-invalid-status-0/218390/1 "2012-03-30T05:15:16Z")

</div>

Hi everyone,

I have a php-fpm backend. And sometimes I got nginx return 502. After I  
check the error\_log I found each 502s are caused by upstream sent  
invalid status “0” while reading response header from upstream

The error\_log are in the form “upstream sent invalid status “0” while  
reading response header from upstream client: 127.0.0.1, server: xxxx,  
request: “xxxxx HTTP/1.0”, upstream:  
“fastcgi://unix:/dev/shm/api-php.socket:”, host: “xxxx”, referrer:  
“xxxx””

Does anyone have same experience? I have no idea after search Google  
‘upstream sent invalid status “0”’

I think it is caused by PHP. But why does it sent status ‘0’?

Yours Sincerely.

Posted at Nginx Forum:

> **[I got 502 and error\_log print upstream sent invalid status "0"](https://forum.nginx.org/read.php?2,224638,224638#msg-224638)**
>
> Hi everyone, I have a php-fpm backend. And sometimes I got nginx return 502. After I check the error\_log I found each 502s are caused by upstream sent invalid status "0" while reading response header from upstream The error\_log are in the...

---

<div class="post-metadata">

**Author:** ![neoesque](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/54ee81/32.png) [@neoesque](https://www.ruby-forum.com/u/neoesque)\
**Post date:** [March 30, 2012, 5:28am UTC](https://www.ruby-forum.com/t/i-got-502-and-error-log-print-upstream-sent-invalid-status-0/218390/2 "2012-03-30T05:28:22Z")

</div>

Hello!

On Thu, Mar 29, 2012 at 11:14:46PM -0400, neoesque wrote:

> “xxxx”"
> 
> Does anyone have same experience? I have no idea after search Google  
> ‘upstream sent invalid status “0”’
> 
> I think it is caused by PHP. But why does it sent status ‘0’?

The message in question means nginx got header line “Status: 0”  
from php. Most likely it’s what you php code did, not php by  
itself.

Maxim D.

---

<div class="post-metadata">

**Author:** ![neoesque](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/54ee81/32.png) [@neoesque](https://www.ruby-forum.com/u/neoesque)\
**Post date:** [March 30, 2012, 5:45am UTC](https://www.ruby-forum.com/t/i-got-502-and-error-log-print-upstream-sent-invalid-status-0/218390/3 "2012-03-30T05:45:11Z")

</div>

Hi, Maxim

Thanks, I’ll check those PHP codes.

Posted at Nginx Forum:

> **[Re: I got 502 and error\_log print upstream sent invalid status "0"](https://forum.nginx.org/read.php?2,224638,224642#msg-224642)**
>
> Hi everyone, I have a php-fpm backend. And sometimes I got nginx return 502. After I check the error\_log I found each 502s are caused by upstream sent invalid status "0" while reading response header from upstream The error\_log are in the...

---

<div class="post-metadata">

**Author:** ![neoesque](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/54ee81/32.png) [@neoesque](https://www.ruby-forum.com/u/neoesque)\
**Post date:** [March 30, 2012, 5:57am UTC](https://www.ruby-forum.com/t/i-got-502-and-error-log-print-upstream-sent-invalid-status-0/218390/4 "2012-03-30T05:57:35Z")

</div>

OH!

You are right, Maxim.

Those errors are retrieving other webpage by using curl. And the  
upstreams return status code 0 seldomly.

Thank you.

Posted at Nginx Forum:

> **[Re: I got 502 and error\_log print upstream sent invalid status "0"](https://forum.nginx.org/read.php?2,224638,224645#msg-224645)**
>
> Hi everyone, I have a php-fpm backend. And sometimes I got nginx return 502. After I check the error\_log I found each 502s are caused by upstream sent invalid status "0" while reading response header from upstream The error\_log are in the...
