Setting up WooCommerce on a WordPress site can sometimes lead to unexpected issues, especially with database connections, payment gateway configurations, and Cloudflare interactions. This guide walks through systematic troubleshooting steps to resolve these problems.
1. Intermittent Database Connection Issues
If your site occasionally displays database connection errors that resolve upon refreshing, the issue may be due to server resources, database settings, or hosting limitations.
Steps to Diagnose and Fix:
- Check Server Resource Usage: High CPU or memory usage can cause temporary database connection failures. Monitor resource consumption in your hosting panel.
- Increase PHP Memory Limit: Add the following line to your
wp-config.php
file to increase the memory limit: - Optimize the Database: Use a plugin like WP-Optimize to clean up overhead in the database.
- Check the Database Credentials: Ensure that
DB_NAME
,DB_USER
,DB_PASSWORD
, andDB_HOST
inwp-config.php
are correct. - Enable Persistent Object Caching: If using an advanced caching plugin or hosting provider, enable Redis or Memcached to reduce database load.
- Investigate Hosting Restrictions: Some shared hosting providers impose strict MySQL connection limits. Contact support if the issue persists.
2. WooCommerce Payments Setup Failure & HTTP 520 Error
HTTP 520 errors typically originate from Cloudflare, suggesting that Cloudflare cannot communicate properly with the origin server.
Steps to Fix:
- Temporarily Disable Cloudflare: In Cloudflare’s dashboard, pause Cloudflare on the site and retry setting up WooCommerce Payments.
- Check Firewall Rules: Ensure that Cloudflare’s firewall isn’t blocking WooCommerce Payments or API requests from WooCommerce/Jetpack.
- Review SSL/TLS Settings:
- Set SSL Mode to “Full” (not “Flexible”) in Cloudflare.
- Ensure the SSL certificate on your origin server is valid.
- Whitelist WooCommerce IPs: If your server has security restrictions, whitelist WooCommerce’s IP addresses to allow communication.
- Enable Debug Mode in WooCommerce: Go to WooCommerce → Settings → Payments and enable logging for WooCommerce Payments to gather error details.
3. Jetpack Connection Failure (cURL Error 52: Empty Reply from Server)
Since WooCommerce Payments relies on Jetpack for authentication, a failed connection to WordPress.com can prevent setup completion.
Troubleshooting Steps:
- Confirm Jetpack is Installed and Activated: Go to Plugins → Installed Plugins and ensure Jetpack is activated.
- Check Site Connectivity with WordPress.com: Use the official Jetpack Debugger to test your connection.
- Verify REST API is Working: Go to
https://yourdomain.com/wp-json/
in your browser. If it doesn’t load, check:- Security Plugins or Firewalls: Some plugins (e.g., Wordfence, iThemes Security) may block API requests. Temporarily disable them.
- .htaccess Rules: Ensure no rules are blocking Jetpack or XML-RPC requests.
- Cloudflare Security Settings: Lower security levels or disable “Bot Fight Mode.”
- Enable cURL Debugging: If running on a dedicated/VPS server, test cURL manually:
If there’s no response, check server logs for cURL or OpenSSL errors.
- Contact Hosting Support: Some hosts block outbound connections to WordPress.com for security reasons. Ask them to allow connections on port 443.
Final Steps: Testing and Re-Enabling Cloudflare
Once WooCommerce Payments is successfully configured:
- Re-enable Cloudflare, but adjust settings to avoid breaking connections:
- Enable Development Mode while testing.
- Exclude WooCommerce & API Endpoints from caching (
/wp-json/*
,/checkout/*
). - Adjust Security Settings to allow Jetpack connections.
By following these steps, you should be able to diagnose and resolve common WooCommerce setup issues related to database errors, Cloudflare conflicts, and Jetpack connection failures.