Fix: WP Cron is Not Working Correctly. Scheduled Backups Do Not Work.

WordPress has a system for performing scheduled tasks in the background. This system does many valuable tasks, such as cleaning up internals, checking for available updates, and performing actions that plugins should do at a particular time or regularly, like creating periodic backups of your website.

If you get a message that your WordPress cron job scheduler doesn’t seem to perform any scheduled tasks, check out the reasons below:

Does Your Website Have Visitors?

If no one has visited your site for a while, then this situation is to be expected. WordPress only gets the opportunity to do something when visitors access the pages. No visitors mean WordPress is never accessed, and WordPress can’t start any scheduled background tasks. So, this message is unsurprising if your site is a staging or development site with no real visitors for other reasons. Visit a few pages, and the message should go away.

WordPress Maintenance Mode Active?

Is your website in maintenance mode? This turns off scheduled tasks of all kinds. So, turn the maintenance mode off to activate the WordPress cron jobs.

Is WP Cron Active or Disabled?

The scheduler of WordPress can be turned off in the configuration of your website. WP STAGING will alert you if this is the case and will show you a warning that DISABLE_WP_CRON is true in the wp-config.php of your site.

You can check this manually as well:

Look in the wp-config.php file (located in the root of your WordPress installation) for the line below and remove it. Optionally, you can change true to false:

PHP
define('DISABLE_WP_CRON', true);

In this case, disabling may be something your web hosting company did intentionally, so be aware that they can turn it off again. However, it may also be something you did deliberately and found another way to access the WordPress scheduler system, perhaps through your web hosting company’s control panel.

In this case, the message about DISABLE_WP_CRON is to be expected. Then, you must ensure the scheduler is called frequently enough to process all the jobs scheduled for your site.

No scheduled backups will run until you have set the scheduler system to invoke it.

Also, note that DISABLE_WP_CRON can be set in a file other than wp-config.php. wp-config.php is simply the most likely location. If you get a warning about DISABLE_WP_CRON, it must be somewhere else, but it’s not in wp-config.php. It would be best if you looked for it.

Are Loopback Connections Working?

Some web hosting providers intentionally, albeit for no good reason, turn off the “loopback” connections that allow WordPress to run its scheduler. This is also the case if your site is password-protected or you run a staging website that is not open to the public.

If the loopback connections don’t work (whether intentionally disabled or not), you can try out using the WordPress alternative scheduling system.

Add somewhere in the middle of your wp-config.php file a line with the following wording:

PHP
define('ALTERNATE_WP_CRON', true);

Don’t add it too late in the file, or it will have no effect.

Is Your Entire Website Password Protected?

Another reason WP Cron and scheduled backups are not working could be that your entire website is password-protected at the HTTP level. This could be done via a .htaccess file.

This also prevents the scheduler of WordPress from working. You should configure your web server to allow “loopback” connections to enable connections to itself. Otherwise, the WordPress scheduler and everything that depends on it will stop working. If you are using Apache and .htaccess, try to add these two lines to the access control section of your .htaccess:

.htaccess
Allow from 0.0.0.0
Satisfy Any

Replace 0.0.0.0 with your website IP address.

Do You Use the Litespeed Webserver?

Look at this article if you use the Litespeed web server and your wp cronjobs do not work.

Updated on February 9, 2024