Not a valid JSON response 📝 WordPress

WordPress: Updating failed. The response is not a valid JSON response.

The block editor saved via the REST API but got HTML or an error page back — broken permalinks, a security plugin/WAF, or PHP output before the JSON.

Seen on: WordPress PHP Cloudflare

Meaning

Gutenberg talks to /wp-json/. If that URL returns a 404/403 page, a ModSecurity block, a login redirect, or JSON polluted by PHP notices, the editor reports this message.

Common causes

  • Permalinks/rewrite rules broken so /wp-json/ 404s
  • Security plugin / ModSecurity / Cloudflare WAF blocking the REST request
  • PHP warnings or BOM printed before the JSON
  • Site URL mismatch (http vs https, www vs non-www) → redirect
  • REST API disabled by a plugin

⚡ Quick fix

  1. Visit https://yoursite.com/wp-json/ — it should show JSON
  2. Re-save Settings → Permalinks
  3. Temporarily disable security/caching plugins
  4. Check browser DevTools → Network for the failing request’s response

Detailed fix by platform

WordPress

  1. Tools → Site Health flags “The REST API encountered an error”. Check siteurl/home match the URL you use, and that .htaccess contains the standard WordPress rewrite block.

How to diagnose

  1. REST — Does /wp-json/ return JSON?
  2. Response — What did the failing request return (DevTools)?
  3. Blockers — WAF / security plugin logs
  4. Output — PHP notices or BOM before JSON?

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.