Bad Gateway 502 While Invoking Web Trigger

I am getting Bad Gateway 502 error when I invoke the web trigger in my app. It was previously working. I can trace the operations inside the runAsync function that works when the web trigger is invoked. They run without any error and produce a valid json as a response but the result is always bad gateway. What might cause this behaviour?
Thanks for the help in advance.