Yoast SEO: “Error parsing the response to JSON” – How to Fix It

Running SEO data optimization in Yoast and getting “Error parsing the response to JSON” especially right after a site migration or import? This guide gives you quick fixes and a deep troubleshooting path, from disabling noisy PHP notices to resetting Yoast’s indexables and reindexing via WP‑CLI. It also covers common post‑migration pitfalls (REST API blocked, URL mismatches, caching, and more).

Yoast shows “Error parsing the response to JSON” when I click Start SEO data optimization. How do I fix this?

This error means the optimization request returned something that wasn’t valid JSON. The most common causes are PHP notices breaking the output, a blocked REST API/WAF, or stale Yoast “indexables” after a migration. Fix it in this order:

1) Eliminate noisy PHP output (quickest win)

  1. Turn off debugging in production: In wp-config.php, make sure:
    define('WP_DEBUG', false);
    define('WP_DEBUG_DISPLAY', false); // or remove if present
    
  2. Retry Yoast → Tools → Start SEO data optimization.

2) Reset Yoast’s indexables, then rerun

  1. Install the free Yoast Test Helper plugin.
  2. Go to Tools → Yoast Test and click:
    • Reset indexables tables & migrations
    • Reset Internal link counter
    • Reset Prominent words calculation (optional)
  3. Return to Yoast → Tools and run SEO data optimization again.

3) Make sure the REST API isn’t blocked

Yoast’s optimizer calls WordPress REST endpoints. If a security plugin, WAF (e.g., Comodo), or server rule blocks /wp-json/ you’ll see 401/403 or JSON parse errors.

  • Visit https://your-site.com/wp-json/. You should see a JSON payload, not a 401/403/HTML page.
  • Temporarily disable security/WAF rules or whitelist REST requests; disable redirect plugins that hijack API calls.

4) Check console/network for status codes

Open your browser DevTools → Network tab, run the optimization again, and look for 301/302 (redirects), 401/403 (blocked), or 500/504 (server errors). Fix the cause you see:

  • 301/302: a redirect plugin or server rule is catching API calls—disable or adjust it.
  • 401/403: REST/API blocked—allow it in the WAF or security plugin.
  • 500/504: check PHP error logs, raise memory/time limits, and try WP‑CLI below.

5) Reindex via WP‑CLI (reliable on busy sites)

Shell into the server and run:

wp yoast index --reindex

If WordPress isn’t in the web root, include --path:

wp --path=/home/account/public_html yoast index --reindex

This bypasses the browser and fills Yoast’s indexable tables directly.

6) Still failing? Quick checklist

  • Environment type: On staging/dev (wp_get_environment_type()production) Yoast may prevent indexation. Switch to production or temporarily override to test.
  • Server pages caching: Purge any reverse proxy/CDN caching (Cloudflare, Nginx microcache) after changes.
  • Admin‑AJAX or cron throttling: If background tasks are blocked, the run can stall—allow admin-ajax.php and ensure WP‑Cron triggers.

Tip: Even if the UI run fails, Yoast still indexes new/updated content over time. Completing a full run improves consistency and speed, so it’s worth finishing.

Why does this error happen right after a migration, and what are the migration-specific fixes?

After a migration, several subtle issues can break the optimizer’s JSON response. Work through these migration checks:

A) URLs and serialization

  • Confirm Settings → GeneralWordPress Address (URL) and Site Address (URL) are correct and match your final domain (no mixed HTTP/HTTPS, no stray subdirectory).
  • If you moved domains/paths, run a proper serialized URL replacement (e.g., WP-CLI wp search-replace or a safe migration tool) across the DB so embedded URLs and serialized arrays aren’t half‑migrated.

B) Authentication keys/salts and cookies

Regenerate auth keys/salts in wp-config.php post‑migration to avoid odd “failed to fetch / cookie check” behaviors:

// Use the WordPress.org secret-key service to generate fresh values
define('AUTH_KEY',         '...');
define('SECURE_AUTH_KEY',  '...');
define('LOGGED_IN_KEY',    '...');
define('NONCE_KEY',        '...');
define('AUTH_SALT',        '...');
define('SECURE_AUTH_SALT', '...');
define('LOGGED_IN_SALT',   '...');
define('NONCE_SALT',       '...');

C) Security layers

  • Temporarily relax WAF/security plugin rules that block /wp-json/ or /wp-admin/admin-ajax.php until the run completes.
  • Ensure basic auth on staging isn’t blocking the optimizer (401/403).

D) Finalize with a clean reindex

  1. Install Yoast Test HelperReset indexables tables & migrations.
  2. Run the optimizer again, or use:
    wp yoast index --reindex
  3. Purge caches/CDN and recheck Yoast notifications.

Need human WordPress help?

WP Assistant is a free tool created by Atiba Software, a WordPress design and development company located in Nashville, TN. If you need more personalized WordPress assistance let us know, and we’ll get back to you ASAP!