Unblocking WP-Cron with Cloudflare: Fixing the Not Working Issue in WordPress

3 min read

If you're a WordPress user who relies on WP-Cron for scheduled tasks and notices that it's not functioning properly after enabling Cloudflare CDN, you're not alone. Cloudflare's security settings can sometimes unintentionally block WP-Cron jobs, causing undesired problems. In this article, we will explore the issue in depth and provide you with practical solutions to resolve the WP-Cron not working issue with Cloudflare CDN.

Understanding WP-Cron

WP-Cron is a built-in feature in WordPress that functions like a Unix cron job, allowing you to schedule and automate tasks on your site at regular intervals. Unlike traditional cron jobs that are scheduled for specific times, WP-Cron runs on each page load and triggers the scheduled tasks.

Some common examples of WP-Cron's functionality include updating real-time sales widgets on the WordPress dashboard, publishing scheduled posts, and executing background tasks for plugins such as database updates and cache purges.

Identifying WP-Cron Issues

When WP-Cron encounters a problem, it directly affects the execution of scheduled tasks on your WordPress site. You may notice failure notices in your dashboard or error logs on your server. For instance, if you use the WP Rocket plugin, which relies on WP-Cron for cache purging, you might experience slower site performance due to outdated cached content not being cleared.

Checking WP-Cron Issues in Cloudflare

Cloudflare's security settings, designed to block malicious bots, can sometimes mistakenly block automated activities such as WP-Cron. To identify if Cloudflare is the culprit behind your WP-Cron issues, follow these steps:

  1. Find your server's IP address: You can locate this information in your hosting panel or by checking the DNS section of your Cloudflare account, where the A record with "@" points to your server's IP address.

  2. Review Cloudflare's security log: Navigate to "Security > Overview" in your Cloudflare account and click on "Add filter." Filter the log based on your server's IP address and look for entries related to "/wp-cron.php," indicating blocked requests.

  3. Access additional details: Scroll down on the page to the activity log section. Here, you can find information about the security service that blocked the request and the action taken. By editing the columns, you can reveal the path ("/wp-cron.php") and the query string ("?doing_wp_cron").

Fixing WP-Cron Issues with Cloudflare

Now that you've confirmed that Cloudflare is causing the WP-Cron not working issue, let's explore the possible solutions to resolve it:

  1. Disable Definitely Automated Bots: If you have a free Cloudflare account, navigate to "Security > Bots" and turn off the "Bot Fight Mode." This setting can inadvertently block WP-Cron as a false positive since WP-Cron is considered an automated process.

  2. Disable Managed Rules under WAF: For premium Cloudflare plan users, go to "Security > WAF" and disable the "Managed rules" option. This will turn off the automatically enabled Web Application Firewall (WAF) rules that may be blocking WP-Cron.

  3. Whitelist Your Server in IP Access Rules: If disabling the WAF ruleset poses a security risk, consider adding an exception for your website's server IP in the Cloudflare WAF settings. Go to "Security > WAF > Tools" and add your server's IP address, selecting the "allow" option. This will prevent your server's activities, including WP-Cron jobs, from being blocked by Cloudflare's firewall.

Further notes...

While Cloudflare is a popular CDN and security service, it may inadvertently interfere with WP-Cron jobs on WordPress sites. By disabling bot protection, excluding your server's IP address, or whitelisting your server in Cloudflare's IP Access Rules, you can overcome the WP-Cron not working issue.

Remember that the solution may vary depending on your Cloudflare plan and the specific security settings you have enabled. By resolving this issue, you can ensure the smooth operation of scheduled tasks and maintain the optimal performance of your WordPress site.