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:
wp-config.php, make sure:
define('WP_DEBUG', false);
define('WP_DEBUG_DISPLAY', false); // or remove if present
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.
https://your-site.com/wp-json/. You should see a JSON payload, not a 401/403/HTML page.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:
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.
wp_get_environment_type() ≠ production) Yoast may prevent indexation. Switch to production or temporarily override to test.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:
wp search-replace or a safe migration tool) across the DB so embedded URLs and serialized arrays aren’t half‑migrated.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', '...');
/wp-json/ or /wp-admin/admin-ajax.php until the run completes.wp yoast index --reindex