If you are on a free CloudFlare account and your host is a little slow you might get that 502 from them. There’s a timeout factor that I think is longer for the paid accounts. That’s only fair… wait states cost server time!
Cloudflare may also be having some resource issues on their own. Unusual!
Next time it happens to you, I’d disable CloudFlare’s Proxy by clicking the orange cloud in the A record from the DNS dashboard. You’ll get a warning that your host’s IP address will be exposed. Your call on that one but if the error goes away you’ll know a possible cause.
CloudFlare support might be able to advise you further from the error logs they might have.