Earlier WordPress was using plain classic editor interface which was more convenient and simple. Later with version 5.0, WordPress introduced Gutenberg blocks editor which make many users unhappy. Though Gutenberg helps to build the site quickly, it also brings lot of problems by using REST API service. One such problem is “Fix Updating Failed. The Response is not a valid JSON response”. If you are stuck with this error in the editor, here is how you can fix.
Not a Valid JSON Response Error in WordPress
This error appears in Gutenberg editor when you try to update or publish a post. You will also see the error automatically appears as the editor tries to autosave the post content periodically.
Whenever you are on the Gutenberg editor, it will use REST API service to contact your hosting server and get a valid response. The error appears when there are not responses from your server due to the problem in the communication. In most cases, the problem does not arise from the server. It happens due to the failure of sending information or conflict within your site. The problem is that you will not be able to update or publish the content without fixing this error.
1. Check Site Health
WordPress has a Site Health feature to check the critical errors happened on your site. Site Health feature also has a section to check the REST API status. This is the first thing you need to check to confirm whether REST API is working on your site. Go to “Tools > Site Health” section, here the issues will be grouped under different categories. If there are no problems, you should see “The REST API is available” item under “Passed tests” section. When there are problems with REST API, you can find a status like “The REST API encountered an unexpected result” under critical issues or recommended improvements section. Expand the message to find more details about the error and understand whether one of your plugins or themes causing the issue.
When you find information, disable the plugin or switch the theme to confirm whether you can able to update or publish the posts.
2. Check Security Plugins and Firewall Setup
If REST API is available on your site, then the most probable reason could be your security setup. The problem comes especially when you use firewall (WAF) setup with services like Cloudflare. When you try to update a post with an embedded content or certain type of files, the firewall rules will be triggered automatically thus preventing the update. As a result, you will see not valid response JSON error in the editor.
The solution is to temporarily turn off your firewall settings and test whether it helps to resolve the problem. If it works, discuss the issue with the developer and add exclusion rules to allow updating your content. Otherwise, you may need to switch the firewall setup to another plugin or service which works for you.
3. Deactivate Plugins and Switch to Default Theme
Core WordPress software will get continuous updates for patching the security vulnerabilities and with new features. However, many free themes and plugins do not catch up with the latest updates. Unfortunately, even commercial themes and plugins can also create conflicts that can affect the REST API in your site. the best way to identify this issue is to disable all the active plugins and switch your theme to one of the default WordPress themes.
Before you do this on the live site, make sure to put the site under maintenance mode so that your visitors will not get different site layout. As an admin, you should be able to edit and view the content with maintenance mode enabled. If the update works without any JSON error, then you can enable the plugins one by one and finally switch to original theme to narrow down the issue to a particular item.
4. Check Site Address
WordPress offers two addresses for your site – one is the address you use in browser’s address bar and other is the physical location of your WordPress installation. In general, these two addresses are same unless you have WordPress installation in different location than your site address. Any issues in the address setup will result in not a valid JSON response error. Go to “Settings > General” section and confirm you have correct WordPress and site address details.
If you see the setup is not correct, enter the correct URL to change the site address and save your changes. Now you can go back to the post editor and test whether you can able to update the content successfully.
5. Check Your Permalinks Structure
Permalinks is the structure of your WordPress URL. WordPress will add few lines of code in your .htaccess based your permalinks setup under “Settings > Permalinks” section. Any conflicts happening due to this permalinks setup will obviously cause not a valid JSON response error in WordPress. If you did not change any setup, simply click “Save Changes” button showing on the bottom of permalinks settings page. this will regenerate the .htaccess entries and resolve any related problems.
6. Switch to Classic Editor
This is not a permanent solution to fix not a valid JSON response error. However, this can help you to update or publish the content in emergency situation. You can check out our article on how to disable Gutenberg editor and use classic editor in WordPress. Basically, you can add a line of code in your functions.php file or install Classic Editor plugin and disable Gutenberg. As mentioned, classic editor does not use REST API and hence you will not see any error related to JSON response while publishing content.
In our case, we had a JSON response problem when converting an old post created with classic editor to blocks. So, the easy option for us was to disable Gutenberg temporarily and update the content with classic editor. after that we disabled classic editor and return back to Gutenberg. Remember, you can’t use the “Classic” block in Gutenberg to solve the problem. This will not make any difference as the editor will still use REST API. Therefore, make sure to completely disable Gutenberg and use classic editor.
Now that you know why 5+ million people are still using Classic Editor plugin. Gutenberg is good but brings technical problems that a normal user may not understand. Fortunately, you always have an option to switch the editors and publish your content. We hope one of the above solutions helped you to fix the not a valid JSON response in your site.