Understanding the Problem
The REST API timeout error (cURL error 28: Operation timed out after 10001 milliseconds with 0 bytes received) typically occurs when:
- Your server is experiencing high load
- There's a plugin or theme conflict
- Your server configuration is too restrictive
- There are DNS or network issues
- Your WordPress installation has performance problems
Diagnosis Results
Server Response Time
Slow
PHP Memory Limit
256M
Active Plugins
35+
REST API Endpoint Accessibility
Timeout
Solutions to Fix REST API Timeout
1. Increase PHP Time Limit
Add this code to your wp-config.php file:
// Increase PHP time limit
set_time_limit(120);
// Increase max execution time
ini_set('max_execution_time', 120);
2. Increase WordPress Memory Limit
Add this to your wp-config.php file:
// Increase WordPress memory limit
define('WP_MEMORY_LIMIT', '256M');
define('WP_MAX_MEMORY_LIMIT', '512M');
3. Optimize Your Server Configuration
If you have access to your php.ini file, adjust these settings:
max_execution_time = 120
max_input_time = 120
memory_limit = 256M
upload_max_filesize = 64M
post_max_size = 64M
4. Identify Problematic Plugins/Themes
Temporarily disable plugins and switch to a default theme to identify conflicts:
- Disable all plugins and check if the issue persists
- If fixed, enable plugins one by one to find the culprit
- Switch to a default theme (Twenty Twenty-One) to rule out theme issues
5. Add Fix to Your Theme's functions.php
Add this code to your theme's functions.php file:
// Increase REST API timeout
add_filter('http_request_args', function($args) {
$args['timeout'] = 30; // Increase timeout to 30 seconds
return $args;
});
// Bypass SSL verification for local requests (if needed)
add_filter('https_ssl_verify', function($verify) {
if (strpos(home_url(), 'localhost') !== false ||
strpos(home_url(), '.local') !== false) {
return false;
}
return $verify;
});
6. Check for DNS Issues
Add this to your wp-config.php to bypass DNS issues:
// Bypass DNS issues
define('WP_HTTP_BLOCK_EXTERNAL', false);
// If you need to allow specific hosts
define('WP_ACCESSIBLE_HOSTS', 'api.wordpress.org,*.github.com');
7. Use a Plugin to Monitor Performance
Install one of these plugins to identify performance bottlenecks:
- Query Monitor
- Debug Bar
- New Relic (server-level monitoring)
Warning: Always test changes on a staging environment before applying them to your live site.
Additional Resources
Server Configuration Check
Contact your hosting provider and ask them to:
- Check server load and resource allocation
- Verify PHP-FPM configuration (if using Nginx)
- Check for firewall restrictions
- Review Apache/Nginx timeout settings
WordPress Optimization
Improve overall WordPress performance:
- Implement caching (WP Rocket, W3 Total Cache)
- Use a CDN for static assets
- Optimize your database regularly
- Limit the number of active plugins
Debugging Mode
Enable WordPress debugging to identify issues:
// Enable debugging in wp-config.php
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
@ini_set('display_errors', 0);
Check the wp-content/debug.log file for errors after enabling this.