502 Bad Gateway error after failed requests using Passenger

Posted by Nicolas Buduroi on Server Fault See other posts from Server Fault or by Nicolas Buduroi
Published on 2011-09-28T20:18:22Z Indexed on 2012/10/19 17:04 UTC
Read the original article Hit count: 315

I've got a staging server running nginx 1.0.5 using Rails 3.1 under Passenger 3.0.9. The problem is that a request sent just after one where there's an application error return 502 Bad Gateway. To test it I've set up a simple controller with an action that just raise a dummy exception. One request will show the Rails error message and the next one will show nginx 502 Bad Gateway error, then it goes back to the Rails application error, etc.

While investigating this problem I've found out that load testing the application (which increase the number of application processes) make that issue disapear. That is until the extra processes are shutdown, then it reappear. I've tried setting the passenger_min_instances option, but doing so doesn't change anything and in this case each time an application error happen one instance is killed while after load testing all instances are kept alive.

P.S.: Some people on my team told me that they've seen the 502 error even when there's no application error but I've not been able to reproduce that.

Update: Just found out how to display the responses status codes using ab and most of them are 502!

© Server Fault or respective owner

Related posts about nginx

Related posts about ruby-on-rails