# 502 Bad Gateway - Nginx + PHP-FPM

**URL:** <https://www.ruby-forum.com/t/502-bad-gateway-nginx-php-fpm/194986>\
**Category:** NGINX\
**Created:** [September 14, 2010, 10:23pm UTC](https://www.ruby-forum.com/t/502-bad-gateway-nginx-php-fpm/194986 "2010-09-14T22:23:28Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![jlangevin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8e8cbc/32.png) [@jlangevin](https://www.ruby-forum.com/u/jlangevin)\
**Post date:** [September 14, 2010, 10:23pm UTC](https://www.ruby-forum.com/t/502-bad-gateway-nginx-php-fpm/194986/1 "2010-09-14T22:23:28Z")

</div>

I’ve noticed a curious issue recently on my server.

I am running Ubuntu 10.04, Nginx, and PHP-FPM using Brian Mercer  
method.

I recently updated the server, and then also updated my PHP-FPM config  
to allow dynamic child processes instead of just static.  
I’ve noticed now that _one_ of my domains (all my domains within the  
same server and same worker group) will periodically hit a 502 Bad  
Gateway error, which remains up for that domain, while other sub domains  
and other websites hosted on my server, have no problem.

Restarting PHP-FPM resolves the issue.

What puzzles me is, why would it toss this error just for _one_ domain,  
not the rest?  
I’m assuming this is actually not a problem in Nginx, but moreso in  
PHP-FPM, regarding the number of processes, requests, etc?

BTW, I realize this is not a support forum for PHP-FPM, but I know many  
Nginx users also use PHP-FPM, so I figured this is one of the better  
locations to get an intelligent response. If my post is completely not  
wanted here, let me know 🙂

All feedback appreciated!

Thanks!

Posted at Nginx Forum:

> **[502 Bad Gateway - Nginx + PHP-FPM](https://forum.nginx.org/read.php?2,130438,130438#msg-130438)**
>
> I've noticed a curious issue recently on my server. I am running Ubuntu 10.04, Nginx, and PHP-FPM using Brian Mercer method. I recently updated the server, and then also updated my PHP-FPM config to allow dynamic child processes instead of just...

---

<div class="post-metadata">

**Author:** ![jlangevin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8e8cbc/32.png) [@jlangevin](https://www.ruby-forum.com/u/jlangevin)\
**Post date:** [September 14, 2010, 10:26pm UTC](https://www.ruby-forum.com/t/502-bad-gateway-nginx-php-fpm/194986/2 "2010-09-14T22:26:23Z")

</div>

Found this in my logs:

`Sep 14 15:24:55.942487 [NOTICE] [pool www] child 29911 started
Sep 14 15:53:45.640790 [WARNING] [pool www] child 29908 exited on signal
11 SIGSEGV after 1730.763352 seconds from start
Sep 14 15:53:45.644145 [NOTICE] [pool www] child 29980 started
Sep 14 16:15:51.861570 [WARNING] [pool www] child 29907 exited on signal
11 SIGSEGV after 3057.712053 seconds from start
Sep 14 16:15:51.865127 [NOTICE] [pool www] child 30041 started`

Posted at Nginx Forum:

> **[Re: 502 Bad Gateway - Nginx + PHP-FPM](https://forum.nginx.org/read.php?2,130438,130440#msg-130440)**
>
> I've noticed a curious issue recently on my server. I am running Ubuntu 10.04, Nginx, and PHP-FPM using Brian Mercer method. I recently updated the server, and then also updated my PHP-FPM config to allow dynamic child processes instead of just...

---

<div class="post-metadata">

**Author:** ![jlangevin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8e8cbc/32.png) [@jlangevin](https://www.ruby-forum.com/u/jlangevin)\
**Post date:** [September 14, 2010, 10:37pm UTC](https://www.ruby-forum.com/t/502-bad-gateway-nginx-php-fpm/194986/3 "2010-09-14T22:37:30Z")

</div>

please post on [http://groups.google.com/group/highload-php-en](http://groups.google.com/group/highload-php-en), I’ll  
answer you.

++ jerome

2010/9/14 jlangevin [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

---

<div class="post-metadata">

**Author:** ![jlangevin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8e8cbc/32.png) [@jlangevin](https://www.ruby-forum.com/u/jlangevin)\
**Post date:** [September 14, 2010, 11:10pm UTC](https://www.ruby-forum.com/t/502-bad-gateway-nginx-php-fpm/194986/4 "2010-09-14T23:10:17Z")

</div>

Done, awaiting moderation.

Posted at Nginx Forum:

> **[Re: 502 Bad Gateway - Nginx + PHP-FPM](https://forum.nginx.org/read.php?2,130438,130451#msg-130451)**
>
> I've noticed a curious issue recently on my server. I am running Ubuntu 10.04, Nginx, and PHP-FPM using Brian Mercer method. I recently updated the server, and then also updated my PHP-FPM config to allow dynamic child processes instead of just...

---

<div class="post-metadata">

**Author:** ![jlangevin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8e8cbc/32.png) [@jlangevin](https://www.ruby-forum.com/u/jlangevin)\
**Post date:** [January 18, 2011, 8:50pm UTC](https://www.ruby-forum.com/t/502-bad-gateway-nginx-php-fpm/194986/5 "2011-01-18T20:50:17Z")

</div>

So I went out to google groups and there seems to have been no  
resolution to this issue.

I used the instructions found here to setup NGINX / PHP-FPM using the  
dotdeb sources in Ubuntu:

> **[Installing PHP 5.3, Nginx And PHP-fpm On Ubuntu/Debian](https://www.howtoforge.com/installing-php-5.3-nginx-and-php-fpm-on-ubuntu-debian)**
>
> Installing PHP 5.3, Nginx And PHP-fpm On Ubuntu/Debian
> 
> Since Apache is most of the time a memory hungy process, people
> started to look for differe...

I’m having tons of 502 errors randomly occur on requests. It’s really  
bad – to figure out how to avoid this problem we set it up the same way  
on another server – same issue.

The only workaround I can figure out is to set a cron job to manually  
restart php-fpm every 5 minutes … I’d like to not have to do that.

Let me know if there’s some way of avoiding this issue…

Posted at Nginx Forum:

> **[Re: 502 Bad Gateway - Nginx + PHP-FPM](https://forum.nginx.org/read.php?2,130438,167331#msg-167331)**
>
> I've noticed a curious issue recently on my server. I am running Ubuntu 10.04, Nginx, and PHP-FPM using Brian Mercer method. I recently updated the server, and then also updated my PHP-FPM config to allow dynamic child processes instead of just...

---

<div class="post-metadata">

**Author:** ![jlangevin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8e8cbc/32.png) [@jlangevin](https://www.ruby-forum.com/u/jlangevin)\
**Post date:** [September 14, 2010, 11:16pm UTC](https://www.ruby-forum.com/t/502-bad-gateway-nginx-php-fpm/194986/6 "2010-09-14T23:16:09Z")

</div>

Discussion of this issue has moved here:  
[http://groups.google.com/group/highload-php-en/browse\_thread/thread/d5ee42be6f8f775a](http://groups.google.com/group/highload-php-en/browse_thread/thread/d5ee42be6f8f775a)

Posted at Nginx Forum:

> **[Re: 502 Bad Gateway - Nginx + PHP-FPM](https://forum.nginx.org/read.php?2,130438,130455#msg-130455)**
>
> I've noticed a curious issue recently on my server. I am running Ubuntu 10.04, Nginx, and PHP-FPM using Brian Mercer method. I recently updated the server, and then also updated my PHP-FPM config to allow dynamic child processes instead of just...

---

<div class="post-metadata">

**Author:** ![jlangevin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8e8cbc/32.png) [@jlangevin](https://www.ruby-forum.com/u/jlangevin)\
**Post date:** [January 18, 2011, 9:16pm UTC](https://www.ruby-forum.com/t/502-bad-gateway-nginx-php-fpm/194986/7 "2011-01-18T21:16:05Z")

</div>

Hehe – @jlangevin that’s great to know – I just started configuring a  
new vm with Maverick just now – looking to see if native packages would  
work better. Thanks!

Posted at Nginx Forum:

> **[Re: 502 Bad Gateway - Nginx + PHP-FPM](https://forum.nginx.org/read.php?2,130438,167340#msg-167340)**
>
> I've noticed a curious issue recently on my server. I am running Ubuntu 10.04, Nginx, and PHP-FPM using Brian Mercer method. I recently updated the server, and then also updated my PHP-FPM config to allow dynamic child processes instead of just...

---

<div class="post-metadata">

**Author:** ![jlangevin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8e8cbc/32.png) [@jlangevin](https://www.ruby-forum.com/u/jlangevin)\
**Post date:** [January 18, 2011, 9:09pm UTC](https://www.ruby-forum.com/t/502-bad-gateway-nginx-php-fpm/194986/8 "2011-01-18T21:09:09Z")

</div>

@supercleanse, Current Ubuntu 10.10 has native packages for PHP 5.3,  
php-fpm (as php5-fpm), nginx, etc.  
After these errors occurred for me, I upgraded my server to 10.10, and  
installed all native packages. No further issues for me.

Posted at Nginx Forum:

> **[Re: 502 Bad Gateway - Nginx + PHP-FPM](https://forum.nginx.org/read.php?2,130438,167338#msg-167338)**
>
> I've noticed a curious issue recently on my server. I am running Ubuntu 10.04, Nginx, and PHP-FPM using Brian Mercer method. I recently updated the server, and then also updated my PHP-FPM config to allow dynamic child processes instead of just...

---

<div class="post-metadata">

**Author:** ![jlangevin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8e8cbc/32.png) [@jlangevin](https://www.ruby-forum.com/u/jlangevin)\
**Post date:** [January 18, 2011, 9:21pm UTC](https://www.ruby-forum.com/t/502-bad-gateway-nginx-php-fpm/194986/9 "2011-01-18T21:21:07Z")

</div>

@supercleanse, as you’re testing a new VM, here’s something else to test  
out if you’re so inclined:  
[https://bitbucket.org/intel352/nginx-vhost/src](https://bitbucket.org/intel352/nginx-vhost/src)

It’s a script for nginx that lets you fairly easily get a new vhost  
ready. I created & use it for my own servers.  
There’s other stuff out there that does this, but I haven’t seen  
anything in native bash, usually perl or ruby/rails.

Cheers

Posted at Nginx Forum:

> **[Re: 502 Bad Gateway - Nginx + PHP-FPM](https://forum.nginx.org/read.php?2,130438,167343#msg-167343)**
>
> I've noticed a curious issue recently on my server. I am running Ubuntu 10.04, Nginx, and PHP-FPM using Brian Mercer method. I recently updated the server, and then also updated my PHP-FPM config to allow dynamic child processes instead of just...

---

<div class="post-metadata">

**Author:** ![jlangevin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8e8cbc/32.png) [@jlangevin](https://www.ruby-forum.com/u/jlangevin)\
**Post date:** [January 18, 2011, 9:35pm UTC](https://www.ruby-forum.com/t/502-bad-gateway-nginx-php-fpm/194986/10 "2011-01-18T21:35:35Z")

</div>

Thanks! That will definitely come in handy 🙂 …

Posted at Nginx Forum:

> **[Re: 502 Bad Gateway - Nginx + PHP-FPM](https://forum.nginx.org/read.php?2,130438,167346#msg-167346)**
>
> I've noticed a curious issue recently on my server. I am running Ubuntu 10.04, Nginx, and PHP-FPM using Brian Mercer method. I recently updated the server, and then also updated my PHP-FPM config to allow dynamic child processes instead of just...
