Are you seeing the cURL error 28: Connection timed out error on your WordPress site?
The cURL error 28 is a common WordPress REST API issue that can affect your website’s performance and may cause it to behave unpredictably.
In this article, we will show you how to easily fix the ‘cURL error 28: Connection timed out’ issue on your WordPress website.
Here is a quick overview of the topics we will cover in this tutorial:
What Is cURL in WordPress?
The cURL is a software utility used by WordPress and many other web applications to send and receive data requests using URLs.
The cURL library plays an important role in how WordPress works behind the scenes. If it is not configured properly, then your WordPress website will not function properly.
What Causes cURL Error 28 in WordPress?
Failure to respond to the server’s data requests in a timely manner causes cURL error 28 in WordPress.
WordPress uses REST API (a programming technique) to send and receive data requests. If these requests time out, then you will see a critical issue in the Site Health report with the title ‘The REST API encountered an error’.
Expanding the error will show you further details, including the error message:
‘Error: cURL error 28: Operation timed out after x milliseconds with x bytes received (http_request_failed)’
You may also see another related issue with the title ‘Your site could not complete a loopback request’. It will have a similar error message with the following description.
‘The loopback request to your site failed, this means features relying on them are not currently working as expected.’
What Can Cause cURL to Time Out?
A number of scenarios may cause the cURL to time out in WordPress.
For instance, a WordPress firewall plugin like Cloudflare may block a REST API request because it considers it to be suspicious activity.
If your DNS server is not working correctly, then this may also fail HTTP requests and cause the cURL timeout error in WordPress.
A poorly configured WordPress hosting server may simply have a very low connection timeout threshold that stops certain WordPress processes from running properly.
That being said, let’s take a look at how to troubleshoot and solve the ‘cURL error 28: Connection timed out issue’ in WordPress.
1. Temporarily Disable the WordPress Firewall
If you are using a WordPress firewall or a security plugin, then go ahead and temporarily deactivate it.
After that, you just need to visit the WordPress Site Health report page to see if your issue has been resolved.
If it has, then simply check your WordPress firewall logs to see which API requests have been blocked.
This would either identify the source of the issue, or you can adjust the firewall settings to not block legitimate API requests.
2. Deactivate All WordPress Plugins
WordPress plugins and WordPress themes make their own API requests to send and receive data. If these calls are too frequent or take too long to complete, then they may cause the cURL error in your Site Health report.
The easiest way to figure out if your WordPress plugins are causing issues is by deactivating all of them. Simply go to the Plugins » Installed Plugins page and select all plugins.
After that, click on the Bulk Actions dropdown menu to select ‘Deactivate’ and then click on the ‘Apply’ button.
You can now visit the Site Health report to see if the issue has disappeared. If this fixed the problem, then you can start activating your plugins and check if one of them causes the error message to reappear.
This will help you find the plugin that may be causing the issue, and you can then ask the plugin author for support.
3. Ensure Your Hosting Server Is Using the Latest Software
The next step is to make sure that your web hosting server is using the latest versions of PHP, cURL library, and OpenSSL.
You can check that by looking at the system information tab on the Tools » Site Health page.
Simply switch to the ‘Info’ tab and expand the ‘Server’ section.
From here, you can get information about software installed on your WordPress hosting server.
Ideally, your server should be using PHP 7.4.13 or higher, cURL version 7.74.0 or higher, and OpenSSL 1.1.1 or higher.
If it doesn’t, then you will need to contact your WordPress hosting company and ask them to update your WordPress to the latest software versions for your hosting account.
4. Fix SSL Insecure Content Issues
If your WordPress site is using HTTPS/SSL, but it is not configured properly, then this could also cause your web server to block insecure cURL requests.
Similarly, if your WordPress site doesn’t use HTTPS/SS, but it made an API call using an HTTPS URL, then those requests will fail too, and you may see the following cURL error instead:
‘Error: cURL error 7: Failed to connect to localhost port 443: Connection refused (http_request_failed)’
To fix this, you can ask your hosting provider to re-install the SSL certificate for your website. If the issue persists, then follow our guide on how to fix common SSL issues to properly set up SSL on your WordPress website.
5. Seek Help from Your Hosting Provider
If the above steps fail to resolve the cURL error 28 on your WordPress site, then the problem is most likely a hosting environment issue.
There are many factors that can only be controlled and fixed by your hosting company. For instance, if their DNS servers are unable to resolve requests in a timely manner, then this will cause cURL requests to time out.
Another scenario could be slower connectivity or networking issues with your hosting server.
If the problem is still there, contact the hosting support team with a support request containing the error details. Then, their technical staff can troubleshoot and apply a fix to solve it.
If your host isn’t very helpful, it might be time to switch to a managed WordPress hosting provider like SiteGround. With SiteGround, you will have access to 24/7 expert technical support, along with blazing-fast servers and premium WordPress security.