Yoast SEO error parsing the response to JSON, and other Yoast errors
Yoast SEO talks to WordPress in the background through the REST API. When you run the SEO data optimisation, open the Yoast panel or save a post, the browser asks your site for a small JSON reply. If anything else comes back instead, such as a PHP warning, a security plugin's block page, a Cloudflare challenge or a server error page, Yoast cannot read it and shows a message such as error parsing the response to JSON. The plugin is rarely the real cause. This guide shows how to see the actual response in your browser and on the server, the usual culprits and their fixes on WordPress, Plesk, Apache, nginx and Cloudflare, and how to rebuild Yoast's indexables once the REST API works again.
- What error parsing the response to JSON means
- Common causes and where to look
- How to see what actually came back
- Fixes on Plesk, Apache, nginx and Cloudflare
- Other Yoast SEO errors and their usual fixes
- A worked example: blocked after a security change
- The fix, step by step
- Edge cases worth knowing
- Keeping Yoast working
- Questions and answers
What error parsing the response to JSON means
Yoast keeps a table of indexables, a compact record of every post, term and archive with its title, description, canonical and links. It builds that table through a series of background requests to REST API addresses under /wp-json/yoast/v1/, and it reads and saves other data the same way when you use the editor panel.
Each request expects a reply that is pure JSON, something like {"objects":[...],"next_url":"..."}. The error appears when the reply cannot be parsed as JSON. That happens when:
- the JSON is there, but something printed text before or after it, such as a PHP notice or a stray blank line;
- the reply is an HTML page instead, such as a 403 block page from a firewall, a login page, a challenge page or a 500 error page;
- the request was redirected to another address and the browser got the wrong document;
- the reply was empty because PHP ran out of memory or time and stopped.
So the message is a symptom. The fix is to find out what came back instead of JSON. The same family of faults causes the block editor's The response is not a valid JSON response message, Yoast's panel failing to load, and the optimisation stopping partway through.
Common causes and where to look
| Cause | What the response looks like | Where to fix it |
|---|---|---|
| PHP notices shown on screen | JSON preceded by Warning: or Deprecated: text | wp-config.php, or the plugin causing the notice |
Blank line or byte order mark before <?php | JSON with a leading space or invisible characters | Theme functions.php or a recently edited plugin file |
| Security plugin restricting the REST API | 401 or 403 with an HTML or JSON block message | Security plugin settings |
| Server firewall such as ModSecurity | 403 HTML page from the server | Plesk or cPanel firewall settings, server rules |
| Cloudflare challenge or WAF rule | HTML challenge page, often status 403 | Cloudflare security rules |
| Caching the REST API | Old or wrong JSON, or a cached HTML page | Caching plugin or CDN exclusions |
| PHP memory or time limit | Status 500 or an empty reply | PHP settings in hosting panel |
| Site address mismatch | 301 or 302 redirect to http or another host | Settings, General, both address fields |
A recent change is the best clue. If the error started after installing a security plugin, moving to a new host, adding Cloudflare or switching on HTTPS, start with that row.
How to see what actually came back
Open the page where the error appears, such as Yoast SEO, Tools. Open Chrome DevTools, choose the Network panel, filter by yoast, and start the optimisation again. Click the request that fails and look at three things: the status code, the response headers, and the Response tab. A 403 with an HTML body names the blocker; a 200 with Warning: before the JSON points to PHP; a 301 shows an address problem.
From a terminal you can test whether the REST API answers with JSON at all. The namespace index is public, so it needs no login:
curl -s -o /dev/null -w '%{http_code} %{content_type}\n' https://example.com/wp-json/
curl -s -o /dev/null -w '%{http_code} %{content_type}\n' https://example.com/wp-json/yoast/v1
curl -s https://example.com/wp-json/yoast/v1 | head -c 300
Both lines should print 200 application/json, and the last should start with {. If you see text/html, a 403, or a redirect, something in front of WordPress is changing the reply.
Turn on logging without showing errors
In wp-config.php, above the line that says to stop editing, log errors to a file instead of printing them into responses:
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );
Run the optimisation again and read wp-content/debug.log. Any fatal error or warning listed during the run names the file and plugin responsible. Also check Tools, Site Health, which runs its own REST API test and reports The REST API encountered an error or an unexpected result when it fails.
Fixes on Plesk, Apache, nginx and Cloudflare
Plesk and ModSecurity
On Plesk, read the domain's error logs first. They live under the vhost system folder:
sudo tail -n 50 /var/www/vhosts/system/example.com/logs/error_log
sudo tail -n 50 /var/www/vhosts/system/example.com/logs/proxy_error_log
sudo grep -i 'wp-json' /var/log/modsec_audit.log | tail -n 20
If ModSecurity is blocking /wp-json/ requests, the audit log shows the rule ID. In Plesk, open the domain's Web Application Firewall settings and switch off that specific rule ID rather than the whole firewall, then test again.
Apache and nginx
Look for rules that deny wp-json in .htaccess or in the nginx server block. Hardening guides sometimes add them to hide the REST API, which breaks the editor and Yoast. Also make sure permalink rules are present: on Apache the standard WordPress block in .htaccess, on nginx a try_files $uri $uri/ /index.php?$args; line in the main location.
Cloudflare
In Security, Events, filter by the path /wp-json/ and see which rule acted. Add a skip or allow rule for requests to /wp-json/ from logged-in sessions, or relax the specific managed rule, rather than turning protection off. Exclude /wp-json/* and /wp-admin/* from any cache everything rule.
If the server returns 500 errors on these requests, the 500 errors guide and the guide to HTTP errors in WordPress cover the server side in more depth.
Other Yoast SEO errors and their usual fixes
- Sitemap shows a 404. Open Settings, Permalinks and click Save to rebuild the rewrite rules. Then check that
/sitemap_index.xmlis not excluded or blocked by your security or caching plugin. See sitemap index problems in WordPress. - Sitemap shows an XML declaration error. A message that the XML declaration is allowed only at the start of the document means something printed whitespace before the sitemap. The cause is the same as the JSON error: a blank line before
<?phpor after a closing?>in a theme or plugin file. - The Yoast panel in the editor is blank or spins. Usually a JavaScript conflict or a blocked REST request. Check the browser console for errors, then deactivate other plugins one at a time on a staging copy.
- Updating failed, the response is not a valid JSON response. The block editor's version of the same problem. Follow the diagnosis above.
- Titles or descriptions not showing on the page. Not an error but a common complaint. The theme may be overwriting the title, or caching is serving an old copy. See Yoast or Rank Math meta description not working.
- Duplicate tags after installing Yoast. Another SEO plugin or the theme is still writing tags. See the WordPress SEO plugin guide.
A worked example: blocked after a security change
Example Bakery added a security plugin and, the same week, Yoast's SEO data optimisation began failing at 4 per cent with error parsing the response to JSON. The Network panel showed the request to an indexing address returning status 403 with an HTML body titled Access denied.
The curl test on /wp-json/ returned 200 application/json, so the REST API itself was working. The security plugin's log showed it had blocked the request because a rule limited REST requests per minute, and the optimisation sends many requests quickly. Raising that limit for logged-in administrators fixed it. The optimisation then completed, and running wp yoast index on the server confirmed every object was indexed.
The lesson is to read the response before changing anything. The plugin that showed the error was not the plugin that caused it.
The fix, step by step
Step 1
Capture the failing request
Open the screen showing the error, open Chrome DevTools, select the Network panel and filter by yoast. Start the SEO data optimisation or repeat the action that failed. Click the red or failed request and note its status code, the content type in the response headers and the first lines of the Response tab. This tells you whether you are dealing with PHP output, a block page, a redirect or a server error.
Step 2
Test the REST API from outside
From a terminal, request /wp-json/ and /wp-json/yoast/v1 with curl and print the status code and content type. Both should return 200 with application/json, and the body should start with a curly bracket. Also open Tools, then Site Health, in WordPress and read the REST API test. If either check fails, the problem is the REST API as a whole, not Yoast, and the fix lies with the server, firewall or a plugin.
Step 3
Log PHP errors instead of printing them
Edit wp-config.php and set WP_DEBUG and WP_DEBUG_LOG to true and WP_DEBUG_DISPLAY to false. This stops notices being printed into JSON replies, which alone fixes many cases. Repeat the failing action, then open wp-content/debug.log and look for warnings or fatal errors logged at that moment. Each entry names a file path, which tells you which plugin or theme is responsible and needs updating or replacing.
Step 4
Remove stray output in theme and plugin files
If the response shows a blank line or odd characters before the JSON, check any file you or a developer edited recently, starting with the theme's functions.php. Make sure nothing comes before the opening <?php tag, and remove any closing ?> at the very end of the file. Save the file without a byte order mark. Repeat the request and confirm the response now begins directly with a curly bracket.
Step 5
Find the security rule that blocks it
If the response is a 401 or 403 page, check your security plugin's log first, then the server firewall. On Plesk, search the ModSecurity audit log for wp-json to find the rule ID. On Cloudflare, filter Security Events by the path. Make an exception for that one rule or for logged-in administrators, rather than disabling protection. Repeat the action and confirm the request now returns status 200.
Step 6
Stop caching REST and admin requests
In your caching plugin, server cache and CDN, exclude /wp-json/ and /wp-admin/ from page caching, then purge all caches. A cached HTML page or a stale JSON reply served to the admin causes the same parse error. Confirm by checking the response headers in DevTools: there should be no cache hit header on the Yoast request, and the content should change when you repeat it.
Step 7
Fix redirects and resource limits
Open Settings, then General, and make sure the WordPress Address and Site Address fields match exactly, including https and www. If the failing request returned 500 or an empty body, raise the PHP memory limit to 256M and the maximum execution time to 120 seconds in your hosting panel, or set WP_MEMORY_LIMIT in wp-config.php. Repeat the request and confirm it now returns status 200 with JSON.
Step 8
Rebuild the Yoast indexables
With the REST API answering cleanly, go to Yoast SEO, then Tools, and run the SEO data optimisation again. On large sites, run wp yoast index on the server instead, adding --reindex if earlier attempts left the data inconsistent. Back up the database before any reindex. Confirm the run completes without errors and the Yoast tools screen no longer asks you to optimise your SEO data.
Step 9
Turn debugging back off and recheck
Set WP_DEBUG back to false, or leave logging on with display off if you want to keep watching, and delete a large debug.log. Open a post in the editor, check the Yoast panel loads and that saving works, and fetch the post with curl to confirm the title and description are correct. Note which rule or plugin caused the error so you can check it first if it ever returns.
Edge cases worth knowing
- Very large sites. Optimising tens of thousands of posts in the browser can hit time limits. Run
wp yoast indexon the server instead, which processes everything without browser requests. - Plain permalinks. The REST API then uses
?rest_route=addresses. It still works, but rules written for/wp-json/will not match, so check both forms when testing firewalls. - Staging copies behind password protection. HTTP basic authentication on a staging site can block background requests. Allow the site's own requests or test with the protection lifted briefly.
- Corrupt indexables. If the REST API works and errors persist, rebuild the table with
wp yoast index --reindex, or use the reset option for indexables in the Yoast Test Helper plugin, then run the optimisation again. Back up the database first. - Object cache problems. A persistent object cache serving stale options can make Yoast think the optimisation is unfinished. Flush it with
wp cache flush.
Keeping Yoast working
Once the REST API answers with clean JSON again, keep it that way:
- Keep
WP_DEBUG_DISPLAYset tofalseon live sites so notices go to the log, never into responses. - Exclude
/wp-json/and/wp-admin/from page caching on every caching layer, from plugins to Cloudflare. - After adding a security plugin, firewall rule or CDN, run the curl test and open the Site Health status screen.
- After large imports or migrations, run
wp yoast indexso the indexables match the content. The WordPress migration guide lists the other checks to make after a move.
1. What does error parsing the response to JSON mean in Yoast SEO?
It means Yoast asked your site for data through the WordPress REST API and got back something that was not valid JSON. The reply might be a PHP warning printed before the data, a firewall block page, a login or challenge page, a redirect or an empty server error. Yoast cannot read it, so it stops. The cause is almost always outside Yoast itself, and you find it by looking at the actual response in the Network panel of your browser's developer tools.
2. Does this Yoast error hurt my SEO?
Not directly, because the error affects Yoast's background data, not the pages visitors and Google receive. Your published titles, descriptions and sitemap usually keep working. However, while the indexables are out of date, Yoast may show stale titles or breadcrumbs for new content, internal link counts will be wrong and some features may not work. If the same REST API block also stops the block editor saving posts, that affects your ability to publish, so fix it promptly.
3. Why does the Yoast SEO data optimisation stop partway?
It stops when one of the many background requests fails, often because a security plugin or firewall limits how many REST requests can be made per minute, or because one batch hits the PHP memory or time limit. Look at the failing request in the Network panel to see its status code. If it is 403 or 429, relax the rate limit for administrators. If it is 500, raise the PHP limits or run wp yoast index on the server instead of in the browser.
4. How do I check if the WordPress REST API is blocked?
Open Tools, then Site Health, in WordPress and read the REST API test, which reports an error or an unexpected result if it is blocked. You can also request your site address followed by /wp-json/ in a browser or with curl. A working API returns a long JSON document with status 200 and a JSON content type. An HTML page, a 401 or 403 status, or a redirect to a login page shows that a plugin, firewall or server rule is blocking it.
5. Can a security plugin cause Yoast SEO errors?
Yes, security plugins are one of the most common causes. Options that restrict the REST API, limit request rates, block unknown user agents or require extra authentication can stop the requests Yoast makes in the background. Check the plugin's activity or firewall log for blocked requests to wp-json addresses at the time of the error. Then add an exception for that rule or for logged-in administrators, rather than switching the whole security plugin off.
6. How do I reset Yoast SEO indexables?
If you have server access, run wp yoast index with the reindex option through WP-CLI, which rebuilds the indexables table from your content. Without a shell, install the Yoast Test Helper plugin, use its option to reset the indexables tables and migrations, then run the SEO data optimisation again from Yoast SEO, Tools. Back up the database before resetting. Only do this after fixing the REST API problem, or the rebuild will fail with the same error.
7. Why does the block editor say the response is not a valid JSON response?
The block editor saves posts through the same REST API that Yoast uses, so it shows this message for the same reasons: PHP notices printed into the reply, a firewall or security plugin blocking the request, a redirect caused by mismatched site addresses, or a cached page returned instead of JSON. Check the failing request in the Network panel, confirm the WordPress Address and Site Address settings match, and make sure wp-json and wp-admin addresses are excluded from caching.
The Site Audit fetches your pages as a search engine does and reports server errors, blocked resources, missing titles and sitemap problems, so you can confirm the front end is healthy once Yoast is working again.
Open Site Audit Fixes โ