Without knowing what your re-syncing process is, and that a 524 is a timeout (it’s taking too long), I can only suggest to bypass Cloudflare during the resync process:
Either the appropriate DNS entries in the Cloudflare Dashboard, or use the Overview section’s lower right corner options to “Pause Cloudflare on Site”.