5xx errors mean that the server is not able to reply to the visitor's request. There are a lot of possible causes, depending on the error. For example:
Issues with the website's code: invalid syntax, incorrect parameters, an incomplete function used, etc;
Issues with plugins or themes causing server overload or logical mistakes;
Issues with order's resources limit being reached.
And many more. Before proceeding with error troubleshooting, double-check that it is not a local cache issue.
If the issue persists even from a proxy, you can check the following articles about specific errors:
Cloudflare 5xx errors: 521, 522, 524, 525, 526, and others
NOTE:
For more information on any 5xx errors encountered on your website, you can check the Analytics section on hPanel