# 502 Bad Gateway

**URL:** <https://www.ruby-forum.com/t/502-bad-gateway/218255>\
**Category:** NGINX\
**Created:** [March 26, 2012, 1:41pm UTC](https://www.ruby-forum.com/t/502-bad-gateway/218255 "2012-03-26T13:41:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [March 26, 2012, 1:41pm UTC](https://www.ruby-forum.com/t/502-bad-gateway/218255/1 "2012-03-26T13:41:58Z")

</div>

Hi all,

I have a simple setup with Nginx in front Apache, under debian wheezy  
(nginx for static content, apache for php)  
Since the last Nginx update (1.1.17-2 via apt-get), every night after  
daily crons i have a 502 error (bad gateway) until i reload apache.  
Everything was fine before.  
I tried to reload apache after nginx in the logrotate daily task, but  
without effect.  
In my logs i just have :

[error] 22332#0: \*10804 connect() failed (111: Connection refused) while  
connecting to upstream

Where should i look at?

Thanks!

---

<div class="post-metadata">

**Author:** ![Raphael\_Marot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9de053/32.png) [@Raphael\_Marot](https://www.ruby-forum.com/u/Raphael_Marot)\
**Post date:** [March 26, 2012, 1:43pm UTC](https://www.ruby-forum.com/t/502-bad-gateway/218255/2 "2012-03-26T13:43:13Z")

</div>

PHP is a common cause of such an error

---

<div class="post-metadata">

**Author:** ![Raphael\_Marot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9de053/32.png) [@Raphael\_Marot](https://www.ruby-forum.com/u/Raphael_Marot)\
**Post date:** [March 26, 2012, 1:45pm UTC](https://www.ruby-forum.com/t/502-bad-gateway/218255/3 "2012-03-26T13:45:43Z")

</div>

Il 26/03/2012 13:41, Raphael Marot ha scritto:

> [error] 22332#0: \*10804 connect() failed (111: Connection refused)  
> while connecting to upstream
> 
> Where should i look at?

Look at Apache’s logs. It seems that apache does not restart correctly  
after che log rotate, and a manual restart fix it. The error tells you  
that nginx can’t communicate with apache.

---

<div class="post-metadata">

**Author:** ![Raphael\_Marot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9de053/32.png) [@Raphael\_Marot](https://www.ruby-forum.com/u/Raphael_Marot)\
**Post date:** [March 26, 2012, 2:01pm UTC](https://www.ruby-forum.com/t/502-bad-gateway/218255/4 "2012-03-26T14:01:54Z")

</div>

Le 26/03/2012 13:45, [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) a crit :

> > In my logs i just have :
> 
> * * *
> 
> nginx mailing list  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [mailman.nginx.org archive](http://mailman.nginx.org/mailman/listinfo/nginx)

Thanks!  
Indeed I have an error in my apache log.  
seg fault or similar nasty error detected in the parent process

It is definitely php related and has nothing to do with Nginx.  
I think i uninstalled a php module which is still called in the php.ini,  
and maybe this is the cause…

---

<div class="post-metadata">

**Author:** ![Raphael\_Marot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9de053/32.png) [@Raphael\_Marot](https://www.ruby-forum.com/u/Raphael_Marot)\
**Post date:** [May 18, 2012, 12:28pm UTC](https://www.ruby-forum.com/t/502-bad-gateway/218255/5 "2012-05-18T12:28:20Z")

</div>

Hello!

On Thu, May 17, 2012 at 07:33:52PM -0400, SolarWonk wrote:

> Any update on this?

The problem was found to be in a backend, not in nginx (well,  
actually it was clear for the original error message referenced,  
and even from the subject). What update do you expect to see  
here?

Maxim D.

---

<div class="post-metadata">

**Author:** ![Raphael\_Marot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9de053/32.png) [@Raphael\_Marot](https://www.ruby-forum.com/u/Raphael_Marot)\
**Post date:** [May 18, 2012, 1:34am UTC](https://www.ruby-forum.com/t/502-bad-gateway/218255/6 "2012-05-18T01:34:28Z")

</div>

Any update on this?

Posted at Nginx Forum:

> **[Re: 502 Bad Gateway](https://forum.nginx.org/read.php?2,224403,226609#msg-226609)**
>
> Hi all, I have a simple setup with Nginx in front Apache, under debian wheezy (nginx for static content, apache for php) Since the last Nginx update (1.1.17-2 via apt-get), every night after daily crons i have a 502 error (bad gateway) until i reload...
