This might be helpful to someone?
I was receiving 'App Failed To Respond (HTTP 502) Bad Gateway' errors when deploying my application on Heroku. Reading the error codes page did not help me solve the problem, it took awhile but I was finally able to track it down.
The error was being generated in the browser but checking the rails logs, the requests were returning HTTP 200 success codes, so the problem was being generated at the web server level on the Heroku stack.
Turns out the problem was caused by setting response.header for no browser caching. I was using code similar to this post. Everything worked fine after I removed this line
- response.headers["Expires"] = 0