Question

Cloudflare 521 Error

I’m running a one-click install WordPress droplet. Lately, my website has been going down for a few minutes at a time. This has been happening about twice a week for the last two weeks — it’s receiving a Cloudflare 521 error. Last night, it went down but didn’t recover.

From what I can tell, 521 has to do with SSL (the server won’t connect to Cloudflare?)

I’ve been using a Cloudflare SSL certificate for years with Cloudflare’s “flexible” SSL/TLS encryption mode. Last night, I tried switching the mode to a “full” (including uploading the certificate and key to my server and updating the available sites config file) but the error persisted.

When that didn’t work, I looked at the apache2 error log (/var/log/apache2/error.log) and saw that there was some sort of interaction with ezoic.com — the platform we use for advertising. Ezoic connects to my site via a WordPress plugin. I deactivated the plugin via FTP and also turned off Ezoic’s services from the Ezoic control panel. This still didn’t help.

After a couple of hours, I ended up restoring the droplet from a backup. It worked, and the site came back online.

This morning, it went down again for a couple of minutes — which is understandable, considering I never really fixed the problem. I’d like to get ahead of it completely crashing again, but I have no idea what might be causing this issue.

I’m not super experienced when it comes to running my own server, so the problem hasn’t been very obvious to me. I’d appreciate any help in figuring out what the problem is. The most recent entries in the apache2 error log are below (replaced my domain with example.com):

* Connection state changed (MAX_CONCURRENT_STREAMS == 250)!
< HTTP/2 200 
< cache-control: private, max-age=0, must-revalidate, no-cache, no-store
< content-type: image/gif
< date: Sat, 29 Jan 2022 17:27:05 GMT
< expires: Fri, 28 Jan 2022 17:27:05 GMT
< server: nginx
< set-cookie: ezCMPCookieConsent=-1=1|1=1|2=1|3=1|4=1; Path=/; Domain=example.com; Expires=Sun, 29 Jan 2023 17:27:05 UTC
< vary: Accept-Encoding
< vary: Accept-Encoding
< x-middleton-display: cmp_storeconsent
< content-length: 43
< 
* Connection #0 to host g.ezoic.net left intact
*   Trying 3.234.104.255:443...
* TCP_NODELAY set
* Connected to g.ezoic.net (3.234.104.255) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: /etc/ssl/certs
* SSL connection using TLSv1.3 / TLS_AES_128_GCM_SHA256
* ALPN, server accepted to use h2
* Server certificate:
*  subject: CN=*.ezoic.net
*  start date: Sep 30 00:00:00 2021 GMT
*  expire date: Oct 31 23:59:59 2022 GMT
*  subjectAltName: host "g.ezoic.net" matched cert's "*.ezoic.net"
*  issuer: C=GB; ST=Greater Manchester; L=Salford; O=Sectigo Limited; CN=Sectigo RSA Domain Validation Secure Server CA
*  SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x55f768447e50)
> GET /ezoic/cookieconsent.min.js HTTP/2
Host: g.ezoic.net
cf-ipcountry: RS
x-forwarded-for: 178.221.98.254
cf-ray: 6d5437d25daa7899-EWR
x-forwarded-proto: https
cf-visitor: {"scheme":"https"}
sec-ch-ua: " Not;A Brand";v="99", "Google Chrome";v="97", "Chromium";v="97"
sec-ch-ua-mobile: ?1
user-agent: Mozilla/5.0 (Linux; Android 9; SM-J330FN) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.98 Mobile Safari/537.36
sec-ch-ua-platform: "Android"
accept: */*
sec-fetch-site: same-origin
sec-fetch-mode: no-cors
sec-fetch-dest: script
referer: https://example.com/book-to-film/disney-passes-on-great-opportunity/
accept-language: sk-SK,sk;q=0.9,sr-RS;q=0.8,sr;q=0.7,en-US;q=0.6,en;q=0.5
cookie: ezoadgid_257060=-1; ezoref_257060=google.com; ezosuibasgeneris-1=80df7406-6faf-448e-4633-b3ae2f295302; ezoab_257060=mod1; active_template::257060=pub_site_mobile.1643477736; ezopvc_257060=1; ezepvv=0; ezovid_257060=789685078; lp_257060=https://example.com/book-to-film/disney-passes-on-great-opportunity/; ezovuuidtime_257060=1643477736; ezovuuid_257060=904ac90a-8c6e-4c46-4926-e41a035763c1
cf-connecting-ip: 178.221.98.254
cdn-loop: cloudflare
referer: https://example.com
x-forwarded-for: 178.221.98.254
x-wordpress-integration: true

* Connection state changed (MAX_CONCURRENT_STREAMS == 250)!
< HTTP/2 200 
< accept-ranges: bytes
< cache-control: max-age=31536000, public
< content-type: application/javascript
< date: Sat, 29 Jan 2022 17:35:37 GMT
< etag: "11a4-5c701b9c2cf40-gzip"
< expires: Sun, 29 Jan 2023 17:35:37 GMT
< last-modified: Tue, 13 Jul 2021 14:05:09 GMT
< server: nginx
< vary: Accept-Encoding
< vary: Accept-Encoding
< x-robots-tag: noindex
< 
* Connection #0 to host g.ezoic.net left intact
*   Trying 3.234.104.255:443...
* TCP_NODELAY set
* Connected to g.ezoic.net (3.234.104.255) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: /etc/ssl/certs
* SSL connection using TLSv1.3 / TLS_AES_128_GCM_SHA256
* ALPN, server accepted to use h2
* Server certificate:
*  subject: CN=*.ezoic.net
*  start date: Sep 30 00:00:00 2021 GMT
*  expire date: Oct 31 23:59:59 2022 GMT
*  subjectAltName: host "g.ezoic.net" matched cert's "*.ezoic.net"
*  issuer: C=GB; ST=Greater Manchester; L=Salford; O=Sectigo Limited; CN=Sectigo RSA Domain Validation Secure Server CA
*  SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x55f7685e8520)
> GET /ezoic/styles/dark-top.css HTTP/2
Host: g.ezoic.net
cf-ipcountry: RS
x-forwarded-for: 178.221.98.254
cf-ray: 6d54381178117899-EWR
x-forwarded-proto: https
cf-visitor: {"scheme":"https"}
sec-ch-ua: " Not;A Brand";v="99", "Google Chrome";v="97", "Chromium";v="97"
sec-ch-ua-mobile: ?1
user-agent: Mozilla/5.0 (Linux; Android 9; SM-J330FN) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.98 Mobile Safari/537.36
sec-ch-ua-platform: "Android"
accept: text/css,*/*;q=0.1
sec-fetch-site: same-origin
sec-fetch-mode: no-cors
sec-fetch-dest: style
referer: https://example.com/book-to-film/disney-passes-on-great-opportunity/
accept-language: sk-SK,sk;q=0.9,sr-RS;q=0.8,sr;q=0.7,en-US;q=0.6,en;q=0.5
cookie: ezoadgid_257060=-1; ezoref_257060=google.com; ezosuibasgeneris-1=80df7406-6faf-448e-4633-b3ae2f295302; ezoab_257060=mod1; active_template::257060=pub_site_mobile.1643477736; ezopvc_257060=1; ezepvv=0; ezovid_257060=789685078; lp_257060=https://example.com/book-to-film/disney-passes-on-great-opportunity/; ezovuuidtime_257060=1643477736; ezovuuid_257060=904ac90a-8c6e-4c46-4926-e41a035763c1; _gid=GA1.2.650417538.1643477740; _gat=1; _ga_LGKRWR12D5=GS1.1.1643477740.1.0.1643477740.0; _ga=GA1.1.1527579511.1643477740; ezds=ffid%3D2%2Cw%3D360%2Ch%3D640; ezohw=w%3D360%2Ch%3D512; __gads=ID=d85afce8a5a524e1:T=1643477740:S=ALNI_MadyX4-GndB6vUDBu0imhUfqDnLbg; ezouspvv=400; ezouspva=1; ezouspvh=400; __qca=P0-1835690291-1643477743958; _hjSessionUser_411183=eyJpZCI6Ijc5M2Y0YzYxLTk4MWUtNTdhMC04MjgyLWEwNDczNWYzYmNhMyIsImNyZWF0ZWQiOjE2NDM0Nzc3NDEyNTMsImV4aXN0aW5nIjpmYWxzZX0=; _hjFirstSeen=1; _hjIncludedInPageviewSample=1; _hjSession_411183=eyJpZCI6IjY0NWRkMmI0LTIwNzUtNGZmNi1hNmYzLTVlNDU5OTQwNTFmNiIsImNyZWF0ZWQiOjE2NDM0Nzc3NDYwMDAsImluU2FtcGxlIjp0cnVlfQ==; _hjAbsoluteSessionInProgress=0
cf-connecting-ip: 178.221.98.254
cdn-loop: cloudflare
referer: https://example.com
x-forwarded-for: 178.221.98.254
x-wordpress-integration: true

* Connection state changed (MAX_CONCURRENT_STREAMS == 250)!
< HTTP/2 200 
< accept-ranges: bytes
< cache-control: max-age=31536000, public
< content-type: text/css
< date: Sat, 29 Jan 2022 17:35:47 GMT
< etag: "b1f-5c701b9c2cf40-gzip"
< last-modified: Tue, 13 Jul 2021 14:05:09 GMT
< server: nginx
< vary: Accept-Encoding
< vary: Accept-Encoding
< x-robots-tag: noindex
< content-length: 2847
< 
* Connection #0 to host g.ezoic.net left intact
[Sat Jan 29 17:50:06.951416 2022] [autoindex:error] [pid 27919] [client 162.158.63.61:49044] AH01276: Cannot serve directory /var/www/html/wp-content/plugins/jetpack/modules/search/: No matching DirectoryIndex (index.html,index.cgi,index.pl,index.php,index.xhtml,index.htm) found, and server-generated directory index forbidden by Options directive

Thank you!


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

alexdo
Site Moderator
Site Moderator badge
April 7, 2023

Hello,

I assume that you’re using a CDN service like CloudFlare. The 521 error will usually occur when there is CDN enabled and it will indicate an issue between your local machine and the server or between the CDN and the server itself.

What I usually recommend is to temporarily disable the CDN in order to determine if the issue lies on the droplet, e.g issue with the web-server (Apache/Nginx) or it is DNS related, or some other issue with the CDN.

Error 521 can also occurs when the origin web server refuses connections from Cloudflare. Security solutions at your origin may block legitimate connections from certain Cloudflare IP addresses.

You can also make sure that port 443 is open with this command:

  1. iptables -A INPUT -p tcp -m tcp --dport 443 -j ACCEPT

Also, you can check our tutorial for whitelisting IPs with iptables:

https://www.digitalocean.com/community/tutorials/iptables-essentials-common-firewall-rules-and-commands#service-web-server

If you’re using CloudFlare you can check this post from their community:

https://community.cloudflare.com/t/how-do-i-temporarily-disable-cloudflare/68798/2

Regards

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

card icon
Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Sign up
card icon
Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We’d like to help.

Learn more
card icon
Become a contributor

You get paid; we donate to tech nonprofits.

Learn more
Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow – whether you’re running one virtual machine or ten thousand.

Learn more ->
DigitalOcean Cloud Control Panel
Get started for free

Enter your email to get $200 in credit for your first 60 days with DigitalOcean.

New accounts only. By submitting your email you agree to our Privacy Policy.

© 2023 DigitalOcean, LLC.