PHP Warning on fresh install (Connection timed out)

I get this PHP Warning when accessing my fresh WordPress 3.4.1 install (Norwegian language).

Warning: fopen(URL_TO_MY_WORDPRESS_PAGE/wp-cron.php?doing_wp_cron=1341476616.7605190277099609375000): failed to open stream: Connection timed out in PATH_TO_MY_WP_FILES/wp-includes/class-http.php on line 923

This is of course with the WP_DEBUG flag set to true, as it’s running on a development server.

Read More

enter image description here

This happens intermittently, so it seems to be a problem with wp-cron.

Is this likely an error in WordPress or something wrong on my server? Should I worry?

The server is a fresh Ubuntu Server 12.04 VM with the LAMP stack.

Google search shows I’m not the only one experiencing this. (See buffered/indexed versions of pages listed to see the actual errors.)

EDIT: I’m also getting this same PHP Warning on the front page. Could it be related to the fact that the webserver is being NATed to? Currently I’ve set up the firewall to point port 19235 to 80 on the development server.

Related posts

Leave a Reply

1 comment

  1. The answer is apparently YES, I should worry. After some research, I’ve found that the warning seems to be related to misconfigurations on the server that WordPress is hosted on (ie. a problem with my server, not WordPress).

    Common misconfigurations:

    1. Server doesn’t have DNS, and so it can’t figure out who “example.com” is, even though it is itself.
    2. Server administrators, in a misguided attempt at security, have blocked “loopback” requests, so it can’t actually make a call back to itself.
    3. Server is running something called “mod_security” or similar, which actively blocks the call due to brain-dead configuration.

    The problem in my case was actually caused by my firewall (pfSense), which has “Disable NAT reflection” by default (listed as common reason #2).

    On the server itself, I tried to reach myself using telnet, and the result was as follows:

    $ telnet external.server.hostname.com 19235
    Trying XXX.XXX.XXX.XXX...
    telnet: Unable to connect to remote host: Connection timed out
    

    To fix this, I had to uncheck Disable NAT reflection on my firewall. In my case, this was in the web interface of pfSense under System->Advanced->Firewall/NAT.
    Source: http://forum.pfsense.org/index.php?topic=3473.0

    enter image description here

    Now I can connect to myself (on the server itself) through the firewall just fine:

    $ telnet external.server.hostname.com 19235
    Trying XXX.XXX.XXX.XXX...
    Connected to external.server.hostname.com.
    Escape character is '^]'.
    

    and I am no longer getting the PHP warning about wp-cron.


    I figured this out after reading this detailed answer regarding wp_cron, explaining how it works.

    Source: http://wordpress.org/support/topic/scheduled-posts-still-not-working-in-282#post-1175405

    As stated in this great and detailed post, if you have no control over your servers configuration or, if applicable, the environment – a workaround is to put

    define('ALTERNATE_WP_CRON', true);

    in your wp-config.php file.