Skip to content

Instantly share code, notes, and snippets.

@sudar
Created February 13, 2013 15:54
Show Gist options
  • Save sudar/4945588 to your computer and use it in GitHub Desktop.
Save sudar/4945588 to your computer and use it in GitHub Desktop.
Increase the curl timeout in WordPress
<?php
Copied from http://fatlabmusic.com/blog/2009/08/12/how-to-fix-wp-http-error-name-lookup-timed-out/
//adjustments to wp-includes/http.php timeout values to workaround slow server responses
add_filter('http_request_args', 'bal_http_request_args', 100, 1);
function bal_http_request_args($r) //called on line 237
{
$r['timeout'] = 15;
return $r;
}
add_action('http_api_curl', 'bal_http_api_curl', 100, 1);
function bal_http_api_curl($handle) //called on line 1315
{
curl_setopt( $handle, CURLOPT_CONNECTTIMEOUT, 15 );
curl_setopt( $handle, CURLOPT_TIMEOUT, 15 );
}
?>
@sasakarastojkovic
Copy link

You can increase the curl timeout in WordPress to, let's say 300, simply by adding this line in your wp-config.php file:
ini_set( 'default_socket_timeout', 300 );
Put this just above the line: /* That's all, stop editing! Happy publishing. */

@Asikur22
Copy link

@jorgecsanz
Copy link

jorgecsanz commented Aug 2, 2022

You can increase the curl timeout in WordPress to, let's say 300, simply by adding this line in your wp-config.php file: ini_set( 'default_socket_timeout', 300 ); Put this just above the line: /* That's all, stop editing! Happy publishing. */

TOP!!!

@kapi14
Copy link

kapi14 commented Nov 15, 2023

Thanks!

@mnajamudinridha
Copy link

great

@Erveeel
Copy link

Erveeel commented Jun 11, 2024

ini_set( 'default_socket_timeout', 300 );

Great - thank you, still works :)

@danielcamus
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment