Fixing curl timeout WordPress 4.9.1
-
Hi there
Need some help to increase the curl timeout on wordpress..What should I edit to increase the curl timeout. Getting an error curl has timed out after 15000ms…..I would appreciate some help with this without bricking my wordpress site. Thanks in advance
-
See if the following info can point you in the right direction:
https://gist.github.com/sudar/4945588https://stackoverflow.com/questions/2582057/setting-curls-timeout-in-php
http://www.wpbeginner.com/wp-tutorials/how-to-fix-secure-connection-error-in-wordpress/
Thanks t-p
But this stuff is more than 5 years old and not applicable anymore. WordPress 4.6 made changes on cURL so the functions above are not applicable any more. Hopefully a wordpress developer can confirm this as info are non existant on current wordpress versions.
Thanks for your help though
Here is an another thread, see if it points you in the right direction:
https://ww.wp.xz.cn/support/topic/curl-error-28-connection-timed-out-after-3001-milliseconds/Thanks t-p for your help!
Sadly not -mine is NOT a DNS issue. It works intermittently if it was dns related it would happen more often. I am looking to change the curl settings changing the code to alter the 5s….There is absolutely no documentation since their 4.6 Update to confirm how to change the curl timeout…..Come now wordpress such a big platform and you have no info on that -shocking !!!!! This is a wordpress issue and NOT a hosting or server error. Its a simple question how do change the wordpress curl timeout settings after 4.6 in WORDPRESS ?
Google search on
documentation how to change the curl timeout:
https://www.bing.com/search?q=documentation+how+to+change+the+curl+timeout&form=EDGEAR&qs=PF&cvid=f0e0acbb74b24dd88f9e35cd8348e978&cc=US&setlang=en-US&PC=LCTSThanks t-p
Nothing as this error is related to WordPress cURL and not php cURL….It amazes me there is no fix for this
bump any wordpress developers here please ?Would appreciate some help here please.Thank you
Here’s what I was able to use for my situation:
add_filter( 'http_request_args', 'fergcorp_debug_url_request_args', 10, 2 ); function fergcorp_debug_url_request_args($r, $url){ if( preg_match("/example\.com/", $url) ){ $r["timeout"] = 10; } return $r; }replace ‘example.com’ with the site you’re having issues with (or just remove that line and the closing brace line completely).
Timeout to however many seconds (ten seconds in the above example).
fergbrain : in which file did you add this? my web host told me that the cURL timeout script is not something that needs to be adjusted by them server side but that I need to put it in the plugin’s files… in my case MainWP is the plugin experiencing issues synching and performing updates to multiple sites.
@metrosuperstar: I have a custom, site-specific plugin I created where I can put things like this. You could also put it in a functions file (https://codex.ww.wp.xz.cn/Functions_File_Explained).
Does this mean that I can drop the code your provided here into my child theme’s functions.php and that should take care of the cURL Timeout issue encountered with this website?
Also, I’m not sure what you meant by ” (or just remove that line and the closing brace line completely).” Can you please provide what that syntax would be in its simplest form?
@metrosuperstar: Yes, you can drop it into your theme’s
functions.phpfile.If you want to only target a specific URL the cURL is having issues with then you’ll also need to replace
example\.comwith the domain name of the URL in question. Otherwise, remove line starting withif( preg_match(...and the closing brace, as shown below, to have it apply for all URL that cURL accesses:add_filter( 'http_request_args', 'fergcorp_debug_url_request_args', 10, 2 ); function fergcorp_debug_url_request_args($r, $url){ $r["timeout"] = 10; return $r; }
The topic ‘Fixing curl timeout WordPress 4.9.1’ is closed to new replies.