The Red Banner of Doom: When Gutenberg Fails
You’ve spent three hours polishing a critical blog post. You hit 'Update,' expecting a green success notification. Instead, a red banner appears: Updating failed. The response is not a valid JSON response. Your work isn't saved, and the error tells you nothing about why.
WordPress saves content via the REST API now. It expects a specific, clean data structure in return. If your server sends back a PHP warning, a 404 page, or a 'Coming Soon' splash screen instead of data, the editor breaks. It’s a ghost in the machine that usually points to a communication breakdown between your browser and the server.
Identifying the Root Cause
To fix this, you have to stop guessing and start looking at the data flow. I’ve found that 90% of these cases are solved by looking at the Network tab.
1. The Browser DevTools Strategy
Open your browser's Developer Tools (F12 or Cmd+Option+I) and select the Network tab. Click 'Update' in WordPress again. You will see a new entry, usually a red line, targeting an endpoint like /wp-json/wp/v2/posts/101.
- 404 Not Found: Your permalink structure is likely broken.
- 403 Forbidden: A security firewall (like Cloudflare or ModSecurity) is blocking the save request.
- 500 Internal Server Error: Your server crashed while trying to process the post, often due to a PHP
memory_limitissue. - 200 OK (but still fails): This is common. It means the server sent a success code, but added a 'Notice: Undefined index' at the start of the file, which ruins the JSON formatting.
2. Reading the Hidden Message
Click on the failed request in the list. Navigate to the Response sub-tab. If you see HTML code starting with <!DOCTYPE html>, the server is serving a webpage where it should be serving raw data. This is your smoking gun.
Field-Tested Solutions
Solution A: The Permalink 'Reset'
Sometimes the internal map for your URLs gets scrambled. Navigate to Settings > Permalinks and simply click Save Changes. You don't need to modify any settings. This forces WordPress to rewrite its .htaccess or Nginx rules, which often restores the REST API path instantly.
Solution B: Solving HTTPS Mismatches
If you recently added an SSL certificate, your site might be in a 'Mixed Content' loop. This happens when your dashboard is HTTPS but the API tries to connect via HTTP. To fix this for sites behind proxies like Cloudflare, add this snippet to the very top of your wp-config.php:
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
$_SERVER['HTTPS'] = 'on';
}
Solution C: Finding the Rogue Plugin
A single poorly coded plugin can echo a PHP warning into the background. This extra text 'pollutes' the JSON response.
- Try installing the Classic Editor plugin. If the error disappears, the issue is definitely with how your theme or plugins interact with the REST API.
- Disable security suites like Wordfence or 'All In One WP Security' temporarily. Check their logs for 'blocked requests' to the
/wp-json/path.
Solution D: Silencing PHP Errors
On production sites, you should never show errors to the user. If WP_DEBUG_DISPLAY is on, it will inject error text directly into your API responses. Turn it off in your wp-config.php:
// Recommended production settings
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
@ini_set('display_errors', 0);
This hides the errors from the editor but saves them to wp-content/debug.log for you to read later.
Verification: How to Know It’s Fixed
Don't just reload the page. Visit yourdomain.com/wp-json/ in your browser. You should see a wall of text that looks like organized code. If you see a '404' or a 'Site under maintenance' page, the API is still blocked, and the 'Invalid JSON' error will persist.
Pro Tip: If the response looks like a jumbled mess, copy the whole block and paste it into the JSON Formatter & Validator at ToolCraft. It will highlight the exact line where a PHP error message is hiding inside your data, saving you from hours of blind troubleshooting.
Final Thoughts
The 'Invalid JSON response' is rarely about the JSON itself. It's a symptom of a 'noisy' server. Start with the Network tab, silence your PHP notices, and keep your permalinks fresh. Most of the time, the fix is just one 'Save Changes' click away.

