Random 520 error


i have been getting random 520 errors for a few weeks now when accessing my Wordpress page. I have checked my PHP logging data and also from my Apache EC2 AWS server. I cannot find an explanation for this issue. Sometimes it comes, after two or three clicks its gone away. It is completely strange.

I have tried everything you can find on your pages:

Error analyics from cloudflare says the 520 errors come from /admin-ajax.php. But I can not see whats the reason for it.

Can you please help me?

I am considering switching to another cdn. The situation is really unacceptable. I checked everything: Access Log Files, if there is something wrong with the scripts, apache logfiles, php log files… I checked with the exact time of Cloudflare’s error but there is simply no explanation for it. Can anyone recommend me another CDN? Maybe Cloudfront?

I’m having the same issues. Cloudflare support responded (fast). Their logs say:
upstream prematurely closed connection while reading response header from upstream and it’s pointing to admin-ajax.php
But my server logs don’t have any issues recorded. Neither apache nor ngnix. Even enabled wp-debug but without any reports there also.
This only occurs on the logged-in users.

If any of you are experiencing this while WAF is enabled, you may want to try toggling it off to rule that out. More likely, though, PHP-FPM or Apache is timing out or crashing in some way. It’ll usually recover on its own, but there won’t always be a log entry.

Do we have any updates on this issue? It’s still active

I hope I could fix the bug. At least it was not show up anymore. I changed the hosts:

sudo nano /etc/hosts

Now I could finally see what happens “behind Cloudflare”. There were still some links on the page without ssl. So the page switched from time to time between secure and insecure.

And the second issue was that under Safari there was a nsposixerrordomain 100 error where the page was completely gone.

Stackoverflow says in this case to disable http/2 in the load balancer of AWS. And that helped. Don’t know what it was from both, but it seems to be fixed. :sweat_smile:

I hope that the error does not come back. Cloudflaire should analyze the error more precisely. Only outputting 520 is not enough.

Hi all,
Do you have any update on this? We keep getting randomly error 520. Did anyone found a working solution? I see on CF’s system status page that these days have a lot of 5xx issues on their network.

Call your host and have them white-label the IP list from cloudflare. Cloudflare sends data through various ip’s and typical servers will throw the 520.

The server is dedicated and CF is whitelisted already. Both IPv4 & IPv6.
We turned off CF and all errors are gone. Strangely there is no error on the server’s logs (apache, nginx, access).
CF support told me that the 520 errors are proxied to CF from the server. I was under the impression that 52x was a CF error.

Got the same issue here !

I openened a support ticket, waiting for a reply. Does anyone has received a reply from CF Team ?

Hi all. Here’s what’s worked for me. Check this: https://support.cloudflare.com/hc/en-us/articles/360029696071-Restoring-original-visitor-IPs-Option-2-Installing-mod-remoteip-with-Apache.
For those who have access to the server configuration, enable the mod_remoteip and configure the httpd.conf via the include editor (Home->Service Configuration->Apache Configuration->Include Editor --> Pre Main Include)
Add there the CF ip’s

i get also 520´s - only randomly (3 times of 10) - but ONLY if i visit my website through our android app (webview)
mobile its working…
disabling the CF proxy - all fine

Are you sure that will fix the problem ?

I’m absolutely positive that it fixed mine. I can’t say about yours because not all faults are the same.