On my website I use wp_remote_get to fetch data from mydomain.com/wp-json/wp/v2/pages/75

When I run it on my localhost it works fine, but after sending to production server (mydomain.com) suddenly I’m getting error: ‘cURL error 28: Operation timed out after 5000 milliseconds with 0 bytes received’ + VPS starts acting crazy (100% cpu usage and memory).

It can’t retrieve data from the same domain. When I changed url to some random REST mockup it is working again.

How can I get data from WP REST on the same domain??

(VPS info: debian 9, php 7.3, curl 7.52.1 and latest wordpress 5.2.2)

Thanks in advance!

1 Answer 1


By default, WordPress set the timeout value for cURL in wp-includes/class-wp-http-curl.php to 5 seconds and the same value is also set to HTTP requests in wp-includes/class-http.php that is a newer class for making HTTP requests that can use also cURL if it’s present in the server.

In your case, 5 seconds was not enough to perform the WP REST call, but it was enough to perform the dummy call. Generally, in terms of doing an HTTP request 5 seconds should be enough in most cases. But it seems in your WP REST endpoint you are doing too much work that need more than 5 seconds.

You can increase the timeout value to any value (15 seconds for example) by the following filter.

function custom_http_request_timeout( ) {
    return 15;
add_filter( 'http_request_timeout', 'custom_http_request_timeout' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.