Nodejs app gives 502 error if cloudflare proxy is turned on

I have hosted an Angular SSR (NodeJs) application in my IIS (Windows VPS).

It is working if Cloudflare Proxy is turned off. But if Cloudflare Proxy is turned on it shows the 502 error, please find the attached screenshot for the same.

Please help with it. we are on live.

There is no screenshot attached, but…

The 502/504 errors are caused by a problem connecting to an upstream server - meaning your server is trying to initiate a process and this fails to work as expected or times out. In most cases of 502 / 504 errors, back-end servers are not communicating correctly. When this happens, you will see color page with Cloudflare branding and the Error 502 Bad Gateway or Error 504 Gateway Timeout. Review this Community Tip for fixing 502 or 504 gateway errors.

This post was flagged by the community and is temporarily hidden.

I also have the same problem

1 Like

Same problem in several of my projects.
It doesn’t depend on my servers.

Some websites are slow and Cloudflare gives 502 or 504 gateway errors. Other websites on the same server through Cloudflar are fast.

I enabled “Development Mode. Temporarily bypass our cache. See changes to your origin server in realtime.” Gateway error goes away!