One of the most common and frustrating errors that WordPress users encounter is the cURL error 28: Connection timed out after X milliseconds. This error typically occurs when WordPress attempts to make a network request (such as retrieving data from an external server or updating plugins) but doesn’t receive a response within the specified time frame. This can cause your website to load slower, or fail to update plugins, themes, or other external resources.
In this guide, we’ll show you how to resolve cURL error 28 in WordPress, ensuring that your site works smoothly again.
What Is cURL Error 28?
cURL is a tool that WordPress uses to make HTTP requests. These requests can include updating plugins, fetching external resources, or connecting to other services. When WordPress fails to complete a request within the set timeout period, it triggers the cURL error 28.
The full error message typically looks like this:
cURL error 28: Connection timed out after X milliseconds
or
cURL error 28: Operation timed out after X milliseconds with 0 out of 0 bytes received
This error usually occurs due to issues with your hosting server, network configuration, or even the third-party service WordPress is trying to connect to.
Common Causes of cURL Error 28
- Server Timeout: Your server may be set to a low timeout value, causing WordPress to give up before it receives a response from an external service.
- Firewall or Security Plugins: Some security tools or firewalls may block external requests, preventing cURL from making a connection.
- DNS Resolution Issues: Incorrect or slow DNS resolution can cause delays in connecting to external servers.
- Heavy Server Load: If your hosting server is under heavy load, it might fail to complete requests on time.
- Slow External Services: The issue could also lie with the external server you’re trying to connect to, particularly if it’s responding slowly or is down.
How to Fix cURL Error 28 in WordPress
1. Increase cURL Timeout Limit
One of the first things to try is increasing the cURL timeout limit. This will give WordPress more time to complete requests.
- Via wp-config.php: You can add a filter to extend the timeout duration:
- Access your WordPress root directory via FTP or File Manager.
- Open the
wp-config.php
file. - Add this line of code just before
/* That's all, stop editing! Happy publishing. */
:
define('WP_HTTP_TIMEOUT', 60);
- This increases the timeout to 60 seconds. You can adjust the number depending on your needs.
2. Check Your Firewall or Security Plugins
If you have a firewall or security plugin installed (like Wordfence, iThemes Security, or a server firewall), it may be blocking outgoing connections, leading to a timeout.
- Disable the firewall temporarily: Disable the security plugin or firewall to check if the error goes away. If it does, you’ll need to configure the firewall to allow outgoing connections.
- Allowlist specific URLs or services: Some firewalls allow you to permit certain domains or IP addresses. If you know the domain WordPress is trying to connect to, add it to the allowlist.
3. Check DNS Settings
Incorrect DNS settings can cause delays when WordPress tries to connect to external services. Ensure that your DNS server is configured correctly:
- Change DNS server settings: If you’re unsure whether your current DNS settings are working well, try changing your DNS servers to more reliable ones, such as Google’s (8.8.8.8 and 8.8.4.4) or Cloudflare’s (1.1.1.1).
- Use a public DNS: Check with your hosting provider to ensure that their DNS servers are functioning properly and aren’t causing delays.
4. Optimize Your Server’s Performance
If your server is under heavy load, it might not be able to handle outgoing requests properly. Here’s how you can improve server performance:
- Upgrade your hosting: If you’re using shared hosting, consider upgrading to a VPS or a dedicated server. These options provide more resources for handling outgoing requests.
- Reduce server load: Optimize your website by reducing the number of running processes, disabling unnecessary plugins, and using a content delivery network (CDN) to offload static content.
- Check for server resource limits: Ensure that your hosting plan has enough resources (such as CPU and memory) to handle the requests WordPress is making.
5. Disable HTTP/2 in Your Server Configuration
While HTTP/2 is faster in many cases, it can sometimes cause connection issues with certain servers. Disabling HTTP/2 may help fix the cURL timeout error.
- Disable HTTP/2 via .htaccess:
- Access your
.htaccess
file. - Add the following lines at the top of the file:
- Access your
# Disable HTTP/2
Header set Connection keep-alive
6. Check for Plugin or Theme Conflicts
Sometimes, a plugin or theme can interfere with WordPress’s ability to make outgoing requests. To check if this is the case:
- Deactivate all plugins: Deactivate all plugins, and then check if the error goes away.
- Switch to a default theme: Switch to a default WordPress theme (like Twenty Twenty-Three) and see if the error is still there.
If the error disappears after deactivating plugins or switching themes, reactivate each one to identify the culprit.
cURL error 28 can be caused by several issues, including server resource limits, DNS issues, or plugin conflicts. By following the steps above, you can increase the timeout limits, optimize your server, and resolve the error, restoring full functionality to your WordPress site. If the issue persists, don’t hesitate to reach out to your hosting provider for additional support.
With these solutions, you’ll be able to get your site back up and running without the hassle of connection timeouts.