Long runtime batch scripts, 520 Error and Page Rules

Why would a long running script get a 520 cache error?

I have a script which takes some time to run. And of course it’s being caught by Cloudflare, so I put a page rule in place and set the following settings:

Disable Security, Web Application Firewall: Off, Security Level: Low, Cache Level: Bypass, Disable Performance

Which I expected would allow the script to bypass the rules and run as long as needed but it hasn’t helped.

Here is the error I am getting:

Error 520 Web server is returning an unknown error
There is an issue between Cloudflare’s cache and your origin web server. Cloudflare monitors for these errors and automatically investigates the cause.

I’m assuming the actual error is not cache related but just a run-time length error. I think actually our server tries to re-run script that timeout so perhaps that is why the error is a 520 instead of an actual timeout error.

So my question is: if page rules don’t work, how do I get around the Cloudflare restrictions on certain pages?

I saw another question on this where the solution was to create a subdomain and have the subdomain not run through cloudflare (or not be proxied anyway) but that isn’t really a viable solution, it would mean I would need two versions of our sites as the way our host does subdomains is they treat it as a separate site so now I have 2 versions of our sites with shared resources/global functions needed in both. It’s just not practical or long term viable for our business so I’m hoping there is a better solution than changing hosting.

Any ideas?

If it’s just you running the script, you can add the origin server’s IP address to a local hosts file on your computer for that hostname. The you’ll be connecting directly to your website without having to worry about your Cloudflare connection timing out.

The maximum response time from your origin is 100s (on Enterprise plans up to 600s). However, the error for exceeding this is 524, so that is probably not happening here.

Have you reviewed the #Community Tip for troubleshooting 520 error issues?

Sort of. It’s not me directly though. It’s from CRON jobs that call scripts on the server. I see your point though. Interesting idea though will put some thought into if this is possible solution. thanks.

1 Like

I did yes but my assumption that the error was wrong meant I didn’t look too deeply. I’ll take another look if you really think it’s a 520

This topic was automatically closed after 14 days. New replies are no longer allowed.