Missed Schedule for wordpress posts due to .htaccess password protection blocking wp-cron.php

I recently set up a private blog that is fully password protected using an .htaccess file. (Users have to enter a username and password to view anything on the blog.) Everything was working well until we tried to set up posts scheduled to publish in the future. They would not post. The dashboard would show “Missed Schedule” and we would have to publish them manually.

After lots of head scratching, I finally figured out what was causing this. Apparently wordpress will call the wp-cron.php file every time a user views a page. HOWEVER, because the web server is doing this, and not the user’s browser, if the wp-cron.php file is protected by a .htaccess user authentication system it will not load (because wordpress doesn’t have the correct username/password!). So none of your scheduled actions will take place.

The solution is to allow (only) that file to be loaded without the normal username/password check in your .htaccess file like this:

#Require username and password for all files!
AuthName "Enter your username and password:"
AuthType Basic
AuthUserFile /home/yourdirectory/.htpasswd
Require valid-user

#Exclude the wp-cron.php file!
<files wp-cron.php>
Order Allow,Deny
Allow from all
Satisfy any
</files>

Of course, if your blog is password protected, the wp-cron.php file won’t get hit until somebody logs in to view the blog…but at that point any tasks that are pending will activate.

5 thoughts on “Missed Schedule for wordpress posts due to .htaccess password protection blocking wp-cron.php

  1. Hello Jay,

    I just spent the good part of last two hours trying to figure out why CRON wasn’t working all of a sudden. I had implemented .htaccess password.

    Thanks for writing this up and for sharing your solution.

    Best regards.

  2. Awesome, my password protected staging site had this problem and was causing me to pull my hair out with strange issues that ended up being cron jobs not running. Really appreciate you sharing this.

Leave a Reply

Your email address will not be published. Required fields are marked *