I have found a solution for the problem scheduling posts for some WordPress users. It seems the problem that I have encountered is for those hosted on Windows IIS as a web server. I don’t know that much about IIS, but it is my understanding that when the server “talks” to the WordPress installation it needs to do this via IP address rather than by domain name. When the server is “talking” to itself, this is called localhost. Any commands sent to localhost are only understood if the command is IP based. In the beginning, the Internet was a relatively small experimental network consisting of large multi-user computer system. It started its life as ARPANET (Advanced Research Projects Agency Network), serving the needs of parts of the United States Department of Defence. The underlying network protocols were a network system named TCP/IP, which gave the network the performance and flexibility to expand into the Internet that we know and love today. TCP/IP consists of two components; TCP (Transmission Core Protocol) and IP (Internet Protocol). It is the IP protocol that this article is concerned with, as the IP system is the part that is coming under so much strain in the modern Internet. Brander Group builds a strong relationship with both our buyers and sellers by providing full transparent, unique tools and access to important information about the IPv4 Block. Brand group is one of the better ipv4 addresses provider, We use a proprietary blacklist software that provides access to information about the IPs that would otherwise only be found through a long and tedious process.
The current incarnation of IP that is in use on the global Internet is IPv4 (Internet Protocol version 4). The addressing system of IPv4 is essentially the same as the one in use in ARPANET. Several clever technologies have emerged over the years to extend the life of IP, but there can be no escaping the fundamental limitation that the address range is simply too small.
An IP address consists of four 8-bit numbers, giving 32 bits in total. A quick delve into binary arithmetic tells us that this gives a total combination of 2 to the power 32 different addresses; i.e. 4,294,967,296 different addresses. In the early days of ARPANET, no-one envisaged a problem where in excess of 4 billion computers could be connected. However, when you consider that several billion of the world’s population are now online, many households have multiple computing devices (e.g. smart televisions, games consoles, tablets, etc.) and a large proportion of the population require Internet access from smart phones whilst away from the home, it is easy to see the limitations of this address scheme.
I don’t think this is always true. I believe there is a setting the webhost can put in the hosts file or another security setting that will also this localhost communication to occur by domain name.
If anyone with more knowledge of IIS is reading this, please correct me if I am wrong. I want to learn more about how this works but for know am basing my assumptions on logic.
I am also not 100% certain that the two users I have assisted with this problem are hosted on IIS but I believe that they are.
Working Toward a Solution
Scheduled posts in the more recent versions of WordPress rely on communication with two files; wp-cron.php and /includes/cron.php. If WordPress is not communicating properly with these files, the scheduled posts will not occur. When cron.php asks wp-cron.php to do it’s job, it is asking for the file by domain name. The request is not understood or is timed out and the scheduled event does not occur. Instead cron.php needs to make the request via the localhost IP address, which is always 127.0.0.1
So, in your WordPress directory, edit /includes/cron.php. At line 84 and 85 replace
$cron_url = get_option( 'siteurl' ) . '/wp-cron.php'; $parts = parse_url( $cron_url );
with
$cron_url = 'http://127.0.0.1/wp-cron.php'; $parts = parse_url( $cron_url );
Then test your next scheduled post and it should work without any problems. Of course, as I always recommend, backup /includes/cron.php before making the edits just in case something goes wrong.
If you don’t feel comfortable making the edit or are unsure what I am talking about, please use my contact information to the right or leave a comment and I can provide some assistance.
How I Got There
I reached this solution through piecing together information from a couple of threads on the WordPress forums.
In this forum thread, it was suggested to create a file from the code below, change example.com to the name of the specific domain, save as a php file, and upload to your WordPress directory. (I called mine file test.php). The path to your WordPress directory will need to be added to the line that begins with fputs, if your blog is in a subdirectory – ex. http://www.example.com/blog rather than http://www.example.com. Then go to the web browser and type in http://yourdomain.com/test.php
$argyle = fsockopen( 'example.com', 80, $errno, $errstr, 0.01 ); if ( $argyle ) { fputs( $argyle, "GET /blog/wp-cron.php HTTP/1.0\r\n" . "Host: example.com\r\n\r\n" ); echo "Success sending the GET.\n"; } else { echo "Error: $errstr ($errno)\n"; }
Running this file determines if the fsockopen php command is communicating with cron.php. I believe fsockopen opens up a “line” for WordPress to send commands to other files. On my server, where I could schedule posts, I got the message ‘Success sending the GET’, which means WordPress was able to communicate with the file responsible for scheduling events. On the site being run on IIS, I received the error, ‘Error 110: Connection Timeout’.
Then in this forum thread someone wrote, “Try replacing example.com with 127.0.0.1 – it will almost certainly fail. Sounds to me like your site is behind a load balancer and it can’t access itself. Your hosts really should have a secure solution to this… ”
So, just as a test on the IIS server, I changed test.php by replacing example.com with the localhost IP address, 127.0.0.1. And, success! The test did not fail and I received the message ‘Success sending the GET’
At this point I knew I needed the localhost IP address but wasn’t sure where it should go. From another post in the WordPress forums someone wrote,
To solve this you need to change this line $cron_url = get_option( 'siteurl' ) . '/wp-cron.php'; to this $cron_url = 'http://127.0.0.1/wp-cron.php' <http://127.0.0.1/wp-cron.php'>;
The thread did not state what file but since the code was referencing wp-cron.php, I correctly assumed it was cron.php
If you are unable to schedule posts in WordPress and are hosted on a Windows IIS server (you can ask your webhost if you are), this solution might correct the problem. It did for one person that I assisted and I am waiting to hear back from the second
If you are having this problem or other WordPress issues, please contact me via the contact information to the right.
Special Thanks
I would like to thank the following people for assistance with this article.
- Jeff from Perishable Press who read my emails and helped me understand what might be happening even though neither of us is experienced with IIS.
- Siel from Green LA Girl who allowed me to test this solution on her site
- Sommer from Green and Clean Mom who also allowed me to test the same solution.
photo credit: jpmatth
Vered - MomGrind says
As I said, I don’t have this problem, but I’m in complete awe of your technical abilities.
Vered – MomGrind’s last blog post – Almost-Wordless Wednesday: Correct Your Nose Without Operation!
Kim Woodbridge says
Hi Vered!
Thanks again. I spent a month on and off actually working on this problem and came to the solution through trial and error and in piecing together other’s code. I’m still not sure about the why it works but I do know the solution works.
Lee says
I’ve never come across this problem myself – is it a widespread issue Kim?
Lee’s last blog post – Harry Potter And The Catholic Church
Kim Woodbridge says
Hi Lee,
I don’t think it is widespread but I know two people who had this problem. There’s been quite a bit of discussion about it on the WordPress forums for over a year.
Lee says
The only gremlin I ever had was the admin panel preventing me from using the visual editor – that probably took a similar amount of effort to resolve!
Overall though, wouldn’t you agree that WordPress is remarkably easy to use considering it’s cost?
Kim Woodbridge says
Was that related to a tinymce file?
Do you prefer the visual editor? I always turn it on off in my settings.
I don’t think WordPress is easy to setup for the average user. I know that many webhosts have a simple install now – I think it’s called fantastico – which makes things easier but your average user doesn’t read instructions, know how to use ftp, set up a database, or change file permissions. So, even if it is setup automatically people don’t know how to fix a problem with htaccess, or chmod files.
To add a basic template, start writing, and publish is very easy. Again, if the user wants to start customizing, I don’t think it is that easy for him. Fortunately, enough people use WordPress that help can be found.
Personally, yes, I think it’s easy. I don’t this how to use it is intuitive – I’m not sure if it’s the design or the instructions.
I used Movable Type for a long time. There were a variety of reasons I stopped using it and things I didn’t like about it but there were many things that I preferred. I’m curious about the new version and am hoping to test it soon.
Lee says
Yes, it was related to a tinymce file – I can’t remember the details now but seem to remember my custom theme didn’t play nicely with it.
I must admit that the initial install of WP is always done through fantastico in my case but, even so, I find it easy to do everything bar modifying the theme.
Even that I can accomplish with a little trial and error.
Can’t comment on Movable Type as I have never used it but WP is much better for me than a custom website or blogspot ever was.
Kim Woodbridge says
By custom website do you mean one that is all coded in html? Those are just too much work now unless you don’t ever update the content :-) I’ve never used blogspot but would recommend it to beginning bloggers who aren’t sure what they are doing and don’t know if they want to pay for hosting.
LJGreene says
Hi Kim, not sure if you’re still monitoring comments to this post, but I’ll take a chance.
I’m not on a Windows server, it’s Linux, but here’s what happened. The shared server I was on was under performing–a nice way for my host to say it totally sucked!–and on Friday night they moved me to a new server. And yes, scheduled posts worked last week, but not this week. The exact thing that you mentioned in your previous post is now happening.
Now I pay for a Linux server, and while my host does have Windows servers as well, I’m fairly sure that’s not what they transferred me to.
Here’s my question. Can I try the same fixes mentioned above? Even though I’m on a different type of server?
Thanks for your insights. (and I’m glad I stumbled across your site, because I found some answers to some other things I’d been wondering if i could do!)
Kim Woodbridge says
Hi,
I answer all my comments :-)
That is interesting – I have not encountered the problem on Linux servers but I suppose it’s possible. It may be a firewall or security setting on the webhost too. You might want to try asking them about it – although in my experience they always say it’s a problem with WordPress.
It won’t hurt anything for you to try the solution – the worst that can happen is that scheduled posts still won’t work. Just make sure that you backup your cron.php file before making the changes – just in case something goes terribly wrong.
And, if it does work, please let me know. That would change my theory as to the cause of the problem and would definitely interest me.
LJGreene says
You can rest! No need to change your theory.
I edited the .php file and did a test, but no go. It’s still doing exactly the same thing.
Oh well, it was worth a try. And i did learn some other neat stuff while I was here, so all was not lost.
Thanks for your help…
LJ
Kim Woodbridge says
LJ,
I was actually hoping it would fix the problem and that my theory would be wrong :-)
Have you talked to your host? In this instance it may be a firewall or security setting.
LJGreene says
I haven’t talked to them, as their CS is notoriously bad.
If you could give me a few more specifics — ie. exactly what to look for, because they generally don’t have a clue — that may be helpful.
I’m guessing you mean firewalls and security settings were changed at their end when they switched servers, but could you verify / clarify?
Thanks so much for your help!
Kim Woodbridge says
Hi LJ,
Honestly, I don’t know too much about that side of it. It’s possible that a security or firewall setting on your host’s server is keeping the scheduled posts from occurring. Was it the same host that moved you to a different server? If so, you have a better argument with them as it worked before they moved you. It has to be something on their end as it worked before the move. What causes problems is that WordPress uses the wp_cron and cron.php files and the webhost automatically thinks cron jobs – which are related but are completely different. A cron job runs a scheduled event but they don’t need to be setup outside of WordPress for the WordPress scheduled events to occur.
I really think that it is something simple on their end which is blocking the scheduled event. But I don’t know specifically what that setting is.
Yohan Perera says
Hi,
I had the same problem, and this is how I solved it.
http://howtogeeksl.com/archives/326
Please be kind enough to leave a comment if you find this useful.
Kim Woodbridge says
@Yohan Thanks for visiting and commenting. I took a look at the article but I’m not sure what the fix was. I’m glad your webhost was able to help you – for the people that I worked with on this problem we were not able to get adequate help from the webhost.
modifoo says
…I’m such a noob – I tried to upload the test.php file you quote, but all I got was the text of that script.
Until I came to realize that I of course have to put “” at the end (without the quotes) of it.
That fixed it.
But turns out this is not the reason I am having trouble with that darn wp-cron.php thing.
Maybe in the end I’ll just re-install wp in the hope that it’ll work…
Anyway, thanks for your write-up.
modifoo´s last blog post – DIY: Fixing Globalmediapro batteries to work with RED One camera
Kim Woodbridge says
Hi modifoo – Thank you for visiting and commenting. Sorry it didn’t work for you. It’s fixed the problem for a couple of people, but unfortunately it isn’t an overall fix. I hope you get the problem worked out.
Matthieu Desiderio says
Kim;
Your solution is great! It works fine with the problem I had on http://www.Transport-Expertise.org and I can now reuse my mailing system integrated in WP + all scheduling functions!
Thank you !
Matt
Matthieu Desiderio´s last blog post – test publication programmée
Kim Woodbridge says
Hi Matthieu – Yay! Finally someone telling me that it worked! Usually people only contact me to tell me that it didn’t. Now I know of three instances where this solution fixed the problem.
TheBigBoss says
Indeed, it works !!! Great post Kim !!
I was getting HTTP wp-cron failure on my local machine (XP, XAMPP) with last version of WP 2.8.4, I tried your test page, got error port 80 msg, changed to 127.0.0.1 and bingo !!
If you working on your localhost and want to get rid of error failure message, open wp-includes/cron.php and type the following
set_transient( 'doing_cron', $local_time );
// ADDED
$form_ip = trim($_SERVER['REMOTE_ADDR']);
if($form_ip=="127.0.0.1") {
$cron_ip_fix = "127.0.0.1";
} else {
$cron_ip_fix = get_option( 'siteurl' );
}
$cron_url = $ip . '/wp-cron.php?doing_wp_cron';
// END ADDED
//$cron_url = get_option( 'siteurl' ) . '/wp-cron.php?doing_wp_cron';
.-= TheBigBoss´s last blog ..Le collage du mardi (60) =-.
TheBigBoss says
Oups sorry, error in previous comment
$cron_url = $ip . ‘/wp-cron.php?doing_wp_cron’;
should be replaced by
$cron_url = $cron_ip_fix . ‘/wp-cron.php?doing_wp_cron’;
.-= TheBigBoss´s last blog ..Le collage du mardi (60) =-.
Kim Woodbridge says
Hi – I’m glad it worked and thank you for the code!! :-)
Chris says
Just a side note. If you have more than one website configured on your IIS server you might have a problem with using the localhost (127.0.0.1) address. It is possible to configure IIS to listen on a specific IP address instead of “All unassigned networks”.
The point being that it might be better to determine the IP address of the web site (ex. 192.168.1.10) instead of using 127.0.0.1. The concept should be the same, connecting to a specific IP address instead of the site name.
.-= Chris´s last blog ..PAC – When a forest trust isn’t enough =-.
Kim Woodbridge says
Hi Chris – Thanks for the info. I had never thought of that problem. Most hosts give you the specific IP for your site so that should be easy enough it use rather than localhost.
daniel says
I have upgraded to wordpress-2.9.1-RC1.zip and seem to have the schedule problem. Cant find the code above in the files to try a solution.Can you tell me which version of wordpress you use to solve the schedule problem.
.-= daniel´s last blog ..Hello world! =-.
Kim Woodbridge says
Hi Daniel – This article is out of date and was for version 2.6 The scheduling issue in 2.9 seems like a different one.
You may want to try this patch, which replaces three files. I’ve used it with 2.9 but not with 2.9.1 RC1
http://www.semiologic.com/2009/12/21/wp-2-9-three-bugs-and-how-to-fix-them/
daniel says
thank you very much!!
I found another patch which is uploading a PHP script(Pugin) from http://blog.5ubliminal.com/. Works well!
Will do the below patch also from what you sent me.
http://kdandcompany.com/strategy/wordpress/missing-your-wordpress-scheduled-posts/
Help more problems:
I deleted all my auto posts created from my amazonautopost plugin and then decided to reimport them/repost them and I keep getting a duplicated post message. Deleted the Amazonautopost and started again and still get the duplicate post message. Can you tell me where I might start to look. The content/config file???? Thanks again for your great job.
.-= daniel´s last blog ..Hair Straighteners =-.
Kim Woodbridge says
Hi Daniel – I think that script forces the cron job to run …?
I don’t have any experience with that plugin – it’s probably best to ask the developer or other people who are using it.
donald says
Do you know how to send your posts to a paticular page or set up your post to go to a particular page. ‘Post to Page’ – plugin. Using wordpress 2.8.6.
Cheers.
Kim Woodbridge says
Hi Donald – Can you provide more information about what you are trying to do? Also, do you have a link to the plugin page – I didn’t locate one called Posts to Page.
And just to be clear, this post is about scheduled posts not about sending posts to a page. :-)