HTTP 502: Bad Gateway
An HTTP 502: Bad Gateway error is rare, but when it does happen it is commonly attributable to the load balancer. The short explanation is that there are a few cases where the proxy software hits an OOM error and is restarted. This causes the load balancer to send back an HTTP 502. The problem is transient and very hard to replicate because of the rareness.
The easiest solution is to simply catch and retry HTTP 502's. If you've seen this several times in a short period of time, please send us an email and we will investigate.