Fixing cURL error 28: Resolving timed out after 5000 milliseconds

I had a previous integration using wp_remote_get but after awhile it suddenly stopped working. Upon checking the logs, I’m now getting a cURL error 28: Resolving timed out after 5000 milliseconds.

Checking the wp_remote_get documentation, I was able to fix it by increasing the timeout args:

$args = array(
'timeout'     => 5000
$response = wp_remote_get( $requesturl, $args );

Another solution that I found is applying the findings by:

To override the cURL timeout using these code:

add_filter('http_request_args', 'fix_wp_curl_timeout', 100, 1);
function fix_wp_curl_timeout( $time )
$time['timeout'] = 10;
return $time;
add_action('http_api_curl', 'adjust_wp_custom_timout', 100, 1);
function adjust_wp_cust_timout( $handle )
curl_setopt( $handle, CURLOPT_CONNECTTIMEOUT, 10 );
curl_setopt( $handle, CURLOPT_TIMEOUT, 10 );

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.