Home About Blog

502 Bad Gateway Error - Upstream Origin Server was Unreachable

Since setting up section.io I regularly get this error.

502 Bad Gateway Error - Upstream Origin Server was Unreachable
Screenshot here: http://screencast.com/t/aoUFZz89Koc

I suspect it is a timeout of some sort, as it regularly occurs when performing functions like reindexing in the magento admin panel.
The error is returned at exactly 60 seconds and occurs every time a process takes longer than this.
It doesn’t seem to interrupt the process, for example if I navigate back to magento, the task has or will generally finish.

Is there a way to change this setting, timeout limit so this error is not returned and instead the browser continues to wait?

Some admin functions can take upwards of several minutes to complete, and this causes Varnish to timeout.
Varnish has a default timeout of 60 seconds for requests that are PASSED.
Furthermore, the default platform timeout is set at 120 seconds.

There are good reasons for these default time outs, as standard HTTP requests shouldn’t take this long.

First reason is security. We don’t let long running requests consume all resources in our platform
This will prevent or reduce the effectiveness of certain forms of malicious traffic.

Second, platform times outs of normal HTTP requests will trigger a spike in 5xx errors which can then be monitored and alerted for. So if the web app is struggling, these alerts can be quickly actioned and reduce the duration that general user experience is affected.

Setting timeouts at a much longer time will expose certain attack vector to the site and platform as well as result in either delayed alerts or no alerts for poor public experience. It is generally recommended to either migrate the admin portal to a different domain that isn’t on the section.io platform, e.g. admin.example.com. Or alternatively, you can perform admin functions directly to the origin, bypassing section.io on a local machine using the HOSTS file.