Wp-json woo api not working with cloudflare

I am facing strange issue from last 2 days on my all website built with WordPress and WooCommerce. If I pause the cloudflare then /wp-json/wc/v3 woo api works and accessible from anywhere but if i keep cloudflare enable then wp-json api is accesible from my local pc but it can not accesible on my own server via WooCommerce PHP package

I set Security → WAF Rule, Rules → Configration Rules and Rules → Page Rules to Disable Security, Security Level: Essentially Off, Cache Level: Bypass

Everything was working fine and normal with current settings. I am facing issue from last 2 days only. I tried everything but not luck only if I pause cloudflare then it works. Can anyone suggest correct solution ?

Getting following error when I access wp-json api on my server via woocommerce composer php package:


Please visit your website and perform the action that would normally result in a request being blocked. Make sure you have Developer Tools open (F12).

If any request to /wp-json/... is blocked with a 403 status code:

  1. Wait a few minutes
  2. Go to Dashboard > Security > Events. If the request was in fact blocked by Cloudflare, you should find an event related to that block action. Depending on your site traffic, you may need to filter by IP address, User Agent, URI Path, etc. to find it. Check the “Service” that blocked it.
  3. If this was
    a) Bot Fight Mode, disable this feature.
    b) Super Block Fight Mode, create a WAF Custom Rule to Skip it for the specific situation, with relevant conditions such as the URI Path and the visitor’s IP, for example;
    c) WAF Managed Rule, you need to create a WAF Exception for that rule. See: Add a WAF exception in the dashboard · Cloudflare Web Application Firewall (WAF) docs
    d) WAF Custom Rule, you need to edit it accordingly.

There is no events showing in Security. Everything was working fine with existing settings done in cloudflare for wp-json. It stopped to work only from last few days suddenly. If I access api from my local pc terminal by running php file then it works fine. but if i run same file on server then it can not able to access the wp-json api. I tried to access api from different servers. I am getting same error. → Fatal error: Uncaught Automattic\WooCommerce\HttpClient\HttpClientException: JSON ERROR: Syntax error in

I think something from cloudflare is preventing not getting what is real issue.

No events logged means Cloudflare is not blocking access.

The mere suspicion that some Cloudflare feature or setting may be causing your server to respond with an error is not enough for anyone in this community to be able to help you. Since the error you’re seeing ins not a Cloudflare error, but an origin-server error, you need to investigate what may be causing it, then provide more details.

I suggest you check the documentation of your plugins for clues, and seek further help from their developers.

Thank you for your suggesion but traffic only passing from cloudflare it means cloudflare only causing the issue. I also talked with hosting company they also advised same.

If I run below php file from my local pc terminal then it works. but same file if i run from server then it not working

  • Local PC Communication: test.php file → Request go threw my ISP → woo api called on perticual domain → Response received OK
  • Server Communication: test.php file uploaded on server on any domain → Access that file via browser as example domain/test.php → then it call woo api via php file but it not working and giving me json error as mentioned above.
    Note: Everything was working fine it stop to work suddenly. I tested on various server facing same issue when cloudflare is on but if i pause cloudflare then it works fine it means the issue only cause by cloudflare not server.


ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);

require_once __DIR__ . '/vendor/autoload.php';

use Automattic\WooCommerce\Client;

$woocommerce = new Client(
    'domain.com', // Your store URL
    'ck_1****2', // Your consumer key
    'cs_8*****3', // Your consumer secret
        'wp_api' => true,
        'version' => 'wc/v3'


I don’t doubt it. If you are on an Enterprise Plan, ask your support team for help. If not, I doubt this community will be able to help with the details provided. It’s on you to dig more info, as no one here has access to your server or knows details of your setup. You should reach out to your website developers, by which I mean Forums | WordPress.org.

It could be an updated theme or plugin.

1 Like

You could also try Development Mode to disable some optimization features that may be interfering.

1 Like