WordPress cURL error 28
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.
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.
WordPress uses cURL to handle several API requests. It is an extension of the PHP programming language, and your WordPress hosting company takes care of that.
The cURL library plays a crucial 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 back 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’ll see it as a critical issue in the Site Health report with the title ‘The REST API encountered in 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 may cause cURL to timeout?
A number of scenarios may cause the cURL to time out in WordPress.
For instance, a WordPress firewall plugin may block a REST API request considering 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 have a very low timeout threshold which may stop specific WordPress processes to run properly.
That being said, let’s take a look at how to troubleshoot and fix the ‘curl error 28: Connection timed out’ issue in WordPress.
1. Temporarily Disable WordPress Firewall
If you are using a WordPress firewall or a security plugin, then go ahead and temporarily deactivate it.
After that, you need to visit the WordPress site health report page to see if your issue has resolved.
If it has, then you need to 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 firewall settings to not block legitimate API requests.
2. Deactivate All WordPress Plugins
WordPress plugins make their own API requests to send and receive data. If these calls are too frequent or take too long to complete, then this may cause the cURL error in your site health report.
The easiest way to figure this out is by deactivating all WordPress plugins. Simply go to the Plugins » Installed Plugins page and select all plugins.
After that, click on the Bulk Actions drop down 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 resolved the issue, then you can start activating your plugins one by one until the issue reappears.
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 WordPress hosting server is using the latest versions of PHP, cURL library, and OpenSSL.
You can check that by looking at the system information tab under Tools » Site Health page.
Simply switch to the ‘Info’ tab and expand the ‘Server’ section. From here you can get the information about software installed on your WordPress hosting server.
Ideally, your server should be using PHP 7.4.13 or higher, curl 7.74.0 or higher, and OpenSSL 1.1.1 or higher.
If it doesn’t, then you need to contact your WordPress hosting company and request them to update the software 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 lead your web server to block insecure cURL requests.
Similarly, if your WordPress site doesn’t use HTTPS / SSL, 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 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 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 timeout.
Another scenario could be slower connectivity or networking issues with your hosting server.
Simply drop them a support request with the error details and their technical staff can troubleshoot and apply a fix to solve it.
Read More - WordPress Migration to Google Cloud (Full Guide)