Occasional 502 Bad Gateway
thesimodi
HOBBYOP

a year ago

I am trying to deploy my oTree application (an open-source experiment/survey tool) an Railway. It is recommended to deploy the app on Heroku but for various reasons I prefer Railway. Everything works like a charm - however, I sometimes receive a 502 Bad Gateway Error (responseDetails: "failed to forward request to upstrean: connection closed unexepectedly").

It only happens infrequently and only when I click through the experiment manually: So far, it never happened with browser bots. It happens on random pages i.e. it seems to be a general problem and not linked to a certain page of the experiment. If I reload the page, I can continue the experiment as if nothing happened. For obvious reasons this is no solution for running the experiment in the field.

I am asking the question here as a last resort as I feel like I searched the entire internet at this point without finding a solution. Would be so grateful for a solution or even just a nudge into the right direction..

My current train of thought: I feel like it happens when I submit pages very fast in succession - this would explain why browser bots have no problem as they only submit the page once. Maybe the server cannot handle multiple similiar requests at the same time? If is observe it correctly, the error also only occurs with POST requests. Maybe, therefore, I need to changes some configuration on how requests are handled..? (nginx configurations..?)

3 Replies

thesimodi
HOBBYOP

a year ago

Below you can find an example screenshot of the error page and the HTTP Logs.


thesimodi
HOBBYOP

a year ago

Quick Update: I also got the same error on a browser bot now. Interestingly, I cannot find it in the HTTP logs


brody
EMPLOYEE

a year ago

A 502 means your app did not answer the incoming request.

I would recommend adding more workers, or using async workers for the web server.


Loading...