When CloudFlare and WordPress don’t get along

It’s the little things… like your website suddenly vanishing.

My website (including this blog) is hosted by Dreamhost, a great company with great service. They offer a lot of one-click installs and generally make it easy to set up a blog or email accounts or mailing lists, etc.

Recently they started offering a free CloudFlare plan to Dreamhost subscribers. CloudFlare offers two benefits: faster webpage loads (by distributing your content across different servers around the world) and community-based protection from spam, bots, crawlers, etc. I thought I’d try it out, so I signed up.

When you check the “CloudFlare” box, Dreamhost warns that you need to allow them to redirect all traffic that comes in as http://mydomain.com/ to http://www.mydomain.com/. This seems harmless enough, and it worked fine for me at first, until I realized that one of my WordPress installations stopped working. Trying to visit http://www.wkiri.com/comphist/ or http://wkiri.com/comphist both resulted in an error: “Too many redirects.” Oddly, my other blog (http://www.wkiri.com/today/) did not have this problem.

I couldn’t find a good, concise description of how to fix this on the web, so I’m posting about it here. Basically, the problem occurs when your WordPress installation has its location specified as http://mydomain.com/something instead of http://www.mydomain.com/something. CloudFlare redirects incoming URL requests to http://www.mydomain.com/, WordPress redirects this to http://mydomain.com/, and so on until the server gets sick of it and tells you “Too many redirects.”

To fix it:

  1. Turn off CloudFlare (otherwise you can’t get in to your WordPress settings). Go to your Dreamhost panel, click “Manage Domains”, then click “Edit” for the domain in question. Scroll down to “CloudFlare Services” and uncheck the box. Scroll down and click “Change settings.”
  2. Keep reloading your WordPress site until it works (i.e., the DNS updates propagate).
  3. Log in to your WordPress site and go to the Dashboard. Click “Settings”. Update the “WordPress Address (URL)” and “Site Address (URL)” fields to have the form http://www.mydomain.com/something. Scroll down and click “Save Changes”.
  4. You may or may not also need to clear your browser’s cookies for this site.
  5. Go back to the Dreamhost panel, re-enable CloudFlare, and save settings.
  6. Everything should now work! (Again, DNS updates have to propagate for CloudFlare to be activated again.)

19 Comments
19 of 35 people learned something from this entry.

  1. Keith Hennessey said,

    May 12, 2012 at 5:05 pm

    (Learned something new!)

    Thank you! You saved me from a big potential headache.

    For others, make sure to clear your browser cache in steps 2 and 6.

  2. Bill Campbell said,

    October 6, 2012 at 5:21 pm

    (Learned something new!)

    Thank you! This works for BlueHost too!

  3. Andrew said,

    October 27, 2012 at 10:15 am

    (Learned something new!)

    Super helpful. Thanks!

  4. Luis Saturno said,

    October 29, 2012 at 11:28 pm

    (Learned something new!)

    Thank you!

    It also works for HostGator!

  5. Dian said,

    January 21, 2013 at 6:55 am

    (Learned something new!)

    You could also just go to the phpmyadmin and change it on the wp database.

  6. Chris said,

    April 7, 2013 at 11:32 pm

    (Learned something new!)

    Life saver! Works with Hostgator for sure!

  7. Mrs Jones said,

    April 9, 2013 at 3:19 am

    (Learned something new!)

    Thanks so much for posting this. I had no idea how to fix the problem before reading.

  8. Daisy said,

    April 20, 2013 at 3:28 pm

    (Learned something new!)

    Thank you! I was already using Cloudflare on two other domains with no problem, and I was tearing my hair out trying to troubleshoot this.

  9. kamil said,

    July 31, 2013 at 3:19 pm

    (Learned something new!)

    found out you can avoid this by integrating Cloudflare via their site (requires changing the DNS on your domain) instead of using the “one-click” features from hosting providers.

  10. elhafez said,

    September 6, 2013 at 4:19 am

    (Learned something new!)

    Thank you very much! really your solution is the way to go.
    i gave up until i found your blog.

    Thanks again

  11. rolf smeets said,

    September 7, 2013 at 2:19 am

    (Learned something new!)

    Fantastic tip. I almost gave up working with wordpress untill I read this tip.
    10 minutes work and it all works again.
    Thanks, Rolf

  12. Paul said,

    October 11, 2013 at 3:08 am

    (Learned something new!)

    Cheers buddy!

  13. Ryan Ronning said,

    February 7, 2014 at 2:43 pm

    (Learned something new!)

    Thank you! I was trying to get this going for our blog and it did the trick! Now I can have a good weekend and not worry about it! Cheers!

  14. Alicia said,

    February 14, 2014 at 4:30 pm

    (Learned something new!)

    Thank you so much!!! Totally fixed the issue I was having. I was this close to starting with a clean slate. And it explains why my other websites had no issue.

  15. ilithya said,

    March 17, 2014 at 6:25 pm

    (Learned something new!)

    Thank you, I’ve been going crazy trying to figure out this! :)

  16. Vanquished said,

    July 8, 2014 at 9:05 am

    (Learned something new!)

    When I changed the URL it locked me out of my site….

    and had to change it back in MySQL.
    I guess I’m not understanding what it is i’m supposed to be changing my urls are set up right now as: “http://adwhois.com”

  17. e─členceli blog said,

    September 10, 2014 at 5:34 am

    Thank you so much!!!

  18. blackberry said,

    May 25, 2019 at 8:48 pm

    (Learned something new!)

    Right now it looks like Movable Type is
    the preferred blogging platform available right now. (from what I’ve read) Is that what you’re
    using on your blog?

  19. Kiri said,

    May 26, 2019 at 9:22 am

    (Knew it already.)

    No, this blog uses WordPress.

Post a Comment

I knew this already. I learned something new!