The dreaded message when making an update to your posts or pages in WordPress Block Editor.
Will all your work be lost? Why won’t this save? Stupid Gutenberg!
Fear not. If you see the error message “Publishing failed. The response is not a valid JSON response.” there should hopefully be a simple fix, and hopefully without you losing your work.
Solutions to “The response is not a valid JSON response“
Here are my solutions to normally fix this problem:
- Re-save Permalinks
- Check you have a .HTACCESS file
- Disable Plugins
- Disable debugging
Before doing any of that, open a new window/tab and access your WordPress Admin screen, then go to Tools > Site Health.
Your Site Health report should show you any errors that could cause this issue.
1) Re-save Permalinks
A frequent one is the JSON API (that the Block Editor uses) has not been properly setup.
To reset your JSON API and other permalinks, go to Settings > Permalinks and then Save. There is no need to update your settings, simple save them again. This flushes your permalinks and should let the JSON API work properly.
2) Check you have a .htaccess file
Go to the root of your WordPress folder (where the sites wp-config.php is) and you should see a .htaccess file. This file includes code that helps WordPress redirect URLs. Make sure the file is there. The file could be hidden – so select any options to show hidden or dot files.
Make sure the htaccess file has the default WordPress htaccess config in it.
3) Disable Plugins
A plugin could be the culprit of the issue. So disable any plugins you have recently upgraded or are non-essential.
4) Disable Debug
If you site is in debug mode, any code that is output through common debugging functions like
print_r could stop the JSON API working. Go to the frontend of your site and see if there is any debug issues. Install a plugin like Query Monitor that should highlight issues. Fix any issues.
After each solution, go back to your post with the JSON response error and try to Save it again. If you have fixed the problem, then the post will save as usual without losing your work.