Report this

What is the reason for this report?

Bad Gateway - error 521 than 502 after setting Cloudflare DNS

Posted on May 21, 2018

Hello, I linked my domain to my wordpress application and everything works. but when I change the DNS to configure CloudFlare, nothing else works and host error. normally everything works fine i can not find the problem. no firewall and the server is UP.

thanks again



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!

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.

Are you able to access your site by the IP address directly? A 521 error from CloudFlare indicates that your web server refused the request sent through from CloudFlare.

I had the same problem when I pointed my website to my new IP. Originally I was with SiteGround but switched hosting to a one click WP Digital Ocean install (Ubuntu 18.04). After updating my DNS with CloudFlare my website went down (both 521 & 502 errors). The fix for me was turning SSL to Off (Flexible allowed the site to open but the format was all messed up). I have an active SSL certificate so I am not really clear as to why it wasn’t working… Will do some more research but for now I am just glad to have my site back up and running.

I resolve the problem with “Really Simple SSL” plugin WP

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.