WP_Error Object in wp_remote_post & wp_remote_get

The cURL error 28 you are encountering indicates that the cURL request used by wp_remote_get and wp_remote_post is timing out. In your case, it’s timing out after 10 seconds (10001 milliseconds) without receiving any response from the server.

Here are a few steps you can take to troubleshoot and potentially resolve this issue:

1. Increase Timeout: You can try increasing the timeout value for your requests. Sometimes, requests can take longer to process, especially if you’re working on localhost or dealing with a remote server with slower response times. You can set a higher timeout value like 30 seconds:

$args = array(
    'timeout' => 30, // Set a higher timeout value
    'sslverify' => false,
);

2. Check Server Availability: Ensure that your WordPress site is running properly on localhost and that the LMFWC REST API is accessible. Try accessing the REST API endpoint directly from your browser to see if it responds.

3. Check URL: Double-check the URL you are using in wp_remote_get and wp_remote_post. Make sure there are no typos or issues with the URL. Also, ensure that the consumer key and secret are correct.

4. Check for Firewall or Security Plugins: If you have any security or firewall plugins active on your WordPress site, they might be blocking external requests. Temporarily disable such plugins and see if the issue persists.

5. Server Resources: If you’re working on localhost, ensure that your local server has enough resources available. Sometimes, resource limitations can lead to timeouts.

6. cURL Version: Ensure that cURL is installed and properly configured on your local server.

7. Check for Rate Limiting: Some APIs have rate limiting in place. Ensure that you are not making too many requests in a short time period.

8. Debugging: You can enable debugging in WordPress to get more detailed error information. Add the following to your wp-config.php file:

define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);

This will log any PHP errors, warnings, or notices to a debug.log file in your WordPress wp-content directory. It might provide more information about the issue.

9. Use localhost IP: Instead of using get_site_url(), you can try using http://127.0.0.1 or http://localhost directly in your URL to see if it makes a difference.

10. Check for Server Load: If you’re running other resource-intensive processes on your local server, they might affect the response time of your cURL requests.

If the issue persists after trying these steps, it may be worth reaching out to LMFWC support or checking their documentation for any specific configuration requirements or known issues related to cURL requests.

error code: 521