cURL 28 error after switch from to brew php 7.2 on localhost

Try This First: Your Problem Might Be DNS

In my testing this is a problem with DNS resolving. In my case it’s because the DNS filter/cache I run on my local network wasn’t responding to requests. After restarting the service on the DNS server my requests got through quickly & easily. I would suggest checking any local DNS servers on your network.

OP also resolved the problem by specifically changing DNS settings to Google’s DNS provider, but I saw elsewhere that for some problem the problem was Google’s DNS, so switching away from Google fixed the problem.


Back to your regularly scheduled answer:

If it’s a CURL_CONNECTTIMEOUT problem, then you I think you can do this:

function filter_request_timeout($timeout) {
    return 100; // desired time in seconds
}
add_filter('http_request_timeout', 'filter_request_timeout' );

Both CURLOPT_CONNECTTIMEOUT and CURLOPT_TIMEOUT use the same value when the timeout is set: https://github.com/WordPress/WordPress/blob/master/wp-includes/class-wp-http-curl.php#L127

However, if this just happened since installing PHP 7.2 maybe there’s another reason. Did you update the cURL extension as well? I’m having the same issue on PHP 7.3 via Homebrew, so I’m going to see what I can do without resorting to adding a filter to the dev version of all my sites.

Update: the http_request_timeout filter is for the default timeout. If the timeout has been set between getting the default and sending the request, it needs to happen in the http_request_args filter:

function johnbeales_filter_request_args( $args, $url ) {

    if(strpos($url, 'wordpress.org') !== false ) {
        $args['timeout'] = 100; // Timeout in seconds
    }

    return $args;
}
add_filter('http_request_args', 'johnbeales_filter_request_args', 10, 2);

Since we’re having trouble connecting to wordpress.org, I only adjusted the timeout on requests to wordpress.org.

Leave a Comment