A record not working in Cloudflare proxy

Have a look at this giude to deal with 502 errors.

https://support.cloudflare.com/hc/en-us/articles/218378978-What-should-I-do-after-seeing-a-502-or-504-gateway-error-on-my-site-