Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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 );
}
?>
@abhimmo
Copy link

abhimmo commented Apr 25, 2017

how to fix curl error 10000 ms

@civid
Copy link

civid commented May 13, 2017

You Sir, save me a lot of time.
Thanks.

@paulewhite
Copy link

paulewhite commented Jul 24, 2018

I was trying to solve a cUrl timeout error and after many attempts, I found this script.
It may be 6 year old but it works like a charm even today.
Thank you very much.

@alexsmithbr
Copy link

alexsmithbr commented May 6, 2019

Awesome! Just tried and it worked as expected (now 7 years later). :)

@ogdy
Copy link

ogdy commented Jun 6, 2019

how to use this?

@sudar
Copy link
Author

sudar commented Jun 7, 2019

@ogdy

Just add the above snippet to your plugin or to the functions.php file of your theme.

@manitra
Copy link

manitra commented Feb 27, 2021

Still working ! thank you

@iohnatan
Copy link

iohnatan commented Mar 18, 2021

great! thanks

@amaheer
Copy link

amaheer commented Apr 8, 2021

Super

@sasakarastojkovic
Copy link

sasakarastojkovic commented Oct 15, 2021

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

Asikur22 commented Feb 28, 2022

@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!!!

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