wp-cron.php Giving You the 404s?

WordPress has a file in the root called “wp-cron.php”; this basically runs periodically (every hour typically) to general house-keeping with your WordPress installation such as delete old files, publish scheduled files and check for updates. A number of caching plugins may also use this file to do some of their own house-keeping.

Some sites might have an issue where the error logs are filling up with 404 pointing towards the wp-cron.php file; this is depsite you can see the file in your WordPress installation.

Checking around the web I can say with 99% certainty that this issue resolves to one place; etc/hosts file on the server. This issue may particularly occur on shared hosting packages. Although I know a little about Linux configurations, I’ve read a little into this issue and will try to explain.

So the etc/hosts basically tells the OS where a particular domain should go to, overriding the DNS gods on the net. So I can set my machine to set google.com to go to a site on my local machine (pranksters take note); so what is happening in the etc/hosts is that there is a configuration line that may look something like wolfiezero.com (where ‘wolfiezero.com’ is would be your domain)

This is the likely issue as probably won’t be pointing to your site folder. So your best bet is to remove that line from the configuration and the wp-cron.php should hopefully work. I believe this links into the idea that if you look the error log it points the wp-cron.php in the folder /var/www/ that may not exist on your server (shared I don’t think use this structure in most cases); not 100% but I think that’s the link as points to this folder that hasn’t got anything in it.

If you don’t have access to etc/hosts or don’t feel comfortable then contact your server admin.

I’m not 100% sure, but from reading around the web this seems to be the solution. I’ve not tried it my self as when I came across this issue, it was better to switch off wp-cron as it wasn’t required. If you rather do that then it’s more simple; go into your wp-config.php file and add this line

define('DISABLE_WP_CRON', true);

Keep in mind you might want to check what your wp-cron should be doing; install this plugin and it will give you a run down of what it does.

If there are any queries on this solution, you spotted an issue in my solution or have another way to solve it then please post a comment.

Hope this helps!