Since the Gutenberg WordPress editor became the default page editor, many WordPress users have started seeing “The response is not a valid JSON response” error messages on their website trying to update posts or upload media. While switching back to the classic editor immediately solves the issue and might be a great temporary fix, WordPress invalid JSON errors indicate an issue with REST API, which WordPress absolutely relies on to work correctly.
In this guide, you will learn how the Gutenberg editor works with REST API and how to fix “The response is not a valid JSON response” message in WordPress in a comprehensive, step-by-step manner.
How Does Gutenberg Work With REST API and JSON?
The Gutenberg WordPress editor, also known as the block editor, is a front-end application that uses REST API to communicate data between the server and user interface. Making it the default option built into WordPress core, WordPress fully replaced the classic editor with Gutenberg, taking a huge step towards full site editing.
The Gutenberg WordPress editor is a client-side application which means that it runs in the user’s browser and does not have direct access to the WordPress database, where all posts and pages are stored. Therefore, the block editor needs a way to communicate with the server to send content updates. REST API is what ensures client-server communication and allows Gutenberg to update posts and pages by sending and receiving data as JSON objects.
What Does “The response is not a valid JSON response” Error Mean?
When the client-server communication is interrupted, or Gutenberg fails to reach the server, WordPress will recognize the message received back as an invalid JSON response and show “The response is not a valid JSON response.”
The WordPress invalid JSON response error can appear on your website when you are trying to update or publish a post from the block editor or upload media. By showing an error message, WordPress informs you that the task you wanted to perform failed. As a result, the update you made will not be saved to the server until normal client-server communication is restored.
Top 5 Issues Behind “The response is not a valid JSON response” Error and How to Address Them
There are 5 main issues behind “The response is not a valid JSON response” error message in WordPress:
- Incorrect WordPress site address setting
- Broken permalinks
- SSL errors and competing redirects
- Security solutions blocking requests
- Plugin conflicts
Incorrect WordPress Site Address Settings
Wrongly configured WordPress Address and Site Address settings will interrupt the correct work of REST API, leading to “The response is not a valid JSON response” message on your WordPress website. Having both settings incorrect can be often seen after website migration or cloning when the URLs have not been updated to reflect the new domain name.
The WP_HOME and WP_SITEURL constants are used by WordPress to identify the address of your website. The WordPress Address setting refers to the location of the WordPress installation, while Site Address represents the URL your visitors need to type in the browser address bar to open your site.
Most of the time, both WP_HOME and WP_SITEURL constant have the same value and are auto loaded from the wp_options table of your WordPress database, where they are stored as the siteurl and home options. Siteurl and home can be found in the first two rows of wp_options. As both settings represent a Uniform Resource Locator, the correct protocol needs to be included.
WordPress Address and Site Address can also be used to force HTTPS on your website, which is often missed when trying to investigate competing redirects. An incorrect protocol specified in siteurl and home can lead to many issues, including the “Too many redirects” error.
How to Address
There are multiple ways to set your WordPress Address and Site Address settings, including modifying your wp-config.php file and WP CLI. But the easiest way to do it is by using the WordPress admin interface.
Open the General Settings menu from your WordPress dashboard and check the WordPress Address and the Site Address settings. Make sure they have the correct website address and protocol used. If you have a valid SSL certificate installed on the server, use HTTPS to ensure secure connections. Correct the values if needed and click on the Save Changes button.
WordPress permalinks are the unique URLs configured for all posts and pages on the website. Broken permalinks will not allow you to save any updates to posts and pages from the block editor, and will lead to seeing “The response is not a valid JSON response” on your website. Moreover, you will see the “404 Page Not Found” error message on all website pages, so no content will be available until you fix the permalink structure.
How to Address
Browse your website to see if all posts and pages load correctly. If you are receiving the “Not Found” error messages, examine the .htaccess file in your WordPress website’s document root directory to make sure the default redirect rules are there.
If the default code is missing, add it manually and save the file. Alternatively, you can resave your permalink structure from the WordPress admin area by navigating to Settings > Permalinks and clicking on the Save Changes button.
SSL Errors and Competing Redirects
Competing redirects, mixed content errors, or other SSL issues can be the reason behind seeing “The response is not a valid JSON response” WordPress error or the “ERR_TOO_MANY_REDIRECTS” message on your website. Let’s review each situation to understand how it affects the functionality of your WordPress website.
SSL Errors and Mixed Content
If your SSL certificate has expired or has not been installed correctly, you will not be able to use HTTPS. If your WordPress website is configured to use secure connections and there are redirects in place to force HTTPS, it will lead to issues.
Competing or Incorrect Redirects
Competing or incorrect redirects can cause a redirect loop on your WordPress website or break client-server communication when using the block editor, leading to “The response is not a valid JSON response” WordPress error. Having competing redirects means that there are at least two redirects, one trying to force HTTPS and the other redirecting back to HTTP.
One of the most common issues you can encounter is having a conflict between the redirects configured on the origin server and the ones applied by the content delivery network used. For example, CloudFlare offers three encryption modes — off, flexible, and full. Choosing the mode, you choose how CDN will request content from your server and deliver it to your website visitors.
A typical situation that causes issues, including “The response is not a valid JSON response” message in WordPress is having HTTPS forced on the server level when you have Cloudflare edge SSL installed, which only allows for encryption between the browser and Cloudflare. In that case, redirects forcing HTTPS configured on the origin server will create issues.
How to Address
The best way to avoid any SSL errors and competing redirects is to have a valid SSL installed, and ensure end-to-end encryption when using a content delivery network. Remember that you will need two certificates installed — one on your origin server and the other provided by the CDN.
Check if your WordPress website has a valid SSL certificate, and install a new one if the previous one has expired. In case your website shows as not fully secure even having a valid SSL certificate installed, mixed content is the most likely cause of seeing “The response is not a valid JSON response” message in WordPress. You can fix mixed content warnings by performing a search-replace on the WordPress database using WP CLI to remove any leftover HTTP references or use a plugin like Really Simple SSL that will do it for you.
You can also temporarily pause your CDN to see where exactly the connection fails. If you do not experience any issues saving post updates in Gutenberg having the CDN disabled, an issue exists in the way CDN communicates with the origin server, or the requests might be blocked by the web application firewall used in combination with your content delivery network.
Security Solutions Blocking WordPress’ Requests
Security solutions used, including WordPress security plugins, web application firewall rules implemented by content delivery network, or server-side WAFs like ModSecurity, can interrupt the correct client-server communication, leading to “The response is not a valid JSON response” message in WordPress.
Each security solution working on the application level presents a set of rules that each request sent to your WordPress websites is checked against in order to minimize the number of malicious requests coming to the web server. Once a certain rule is triggered, the request is blocked and an error message is returned, causing WordPress invalid JSON response errors shown.
How to Address
The best way to track down the issue is to check server and WAF logs to see if the request was actually blocked, and one of the security solutions is what caused the “The response is not a valid JSON response” error message to be shown. If you can not do it, deactivate your WordPress security plugin and any other solutions like Cloudflare WAF to see if it addresses the issue.
If it does, reach out to the plugin support team to help identify the rule-causing issues, or examine the list of rules yourself if there is an option for it. If you are still unable to save any updates from the block editor or upload media, a server-side security solution might be at fault. Your web hosting support team can help you address the issue by whitelisting the rule triggered for your IP address, or the website URL.
Make sure you are using a great WordPress security plugin that has managed rulesets that provide great protection against malicious requests, but at the same time do not interrupt you from performing website administration tasks. iThemes Security Pro actively monitors suspicious activity and helps you secure the most vulnerable parts of your WordPress website. Having the Site Scan feature enabled, you can be sure — no malware will go unnoticed.
When it comes to WordPress, plugin conflicts are one of the most common reasons why errors occur, including issues with REST API and having the “The response is not a valid JSON response” shown when trying to update posts and pages or upload data. The more plugins are activated at once, the higher the chance of code incompatibility, which in most cases won’t remain unnoticed.
How to Address
Deactivate all plugins to see if it solves the problem. If you no longer see the “The response is not a valid JSON response” error message, and all post updates made from the block editor are saved correctly, reactivate plugins one by one to identify the one causing issues.
You may notice that a certain plugin has recently been updated, so you may need to roll back the update to go back to the version that worked correctly. Check the plugin users’ support requests to see if others experienced the same issue. It is possible that the problem will be addressed in the next release or there is a known fix that will allow you to keep using the plugin.
iThemes Security Version Management allows you to auto-update WordPress, plugins, and themes to leverage new features, stay protected from known vulnerabilities, and avoid any interruptions to the correct work of your WordPress website.
How To Fix Not Valid JSON Response WordPress Error in 3 Steps
With various issues that can cause the “The response is not a valid JSON response” error message to appear on your WordPress website, it can be difficult to troubleshoot it and understand where to start. Do not rush into applying all fixes outlined in this guide. Follow the steps below to fix WordPress invalid JSON response errors once and for all.
Step 1. Identify Any Recent Changes
Start with doing a basic check of your website. See when the last WordPress core and plugin updates were performed and think whether anything might have changed on your website since the last time you were able to save content updates from the block editor and upload media to your website.
You may realize that a plugin has been recently updated, a new set of rules was added to your web application firewall, or you had to restore your website from a backup because it had been hacked. Knowing what exactly happened that caused the “The response is not a valid JSON response” error message will greatly help you understand where to start and save you time and effort.
Step 2. Examine Your WordPress Website
To fix the “The response is not a valid JSON response” error message in WordPress, the scope of search needs to be limited. Most of the issues described in the previous section of this article will cause more serious issues than just an inability to save content updates in Gutenberg or upload media.
Browse your website pages
Browse your website to see if you can load all web pages, and your browser shows the connection as fully secure on all of them. As a result, you can easily determine if there are any issues with SSL, your permalink structure, or redirects. Broken permalinks will result in the “Not Found” error messages shown on web pages, conflicting redirects may lead to seeing “ERR_TOO_MANY_REDIRECTS”.
Check your WordPress address settings and SSL
Check your WordPress address settings, including the protocol used in the URLs, and make sure your SSL certificate is valid and is trusted by all browsers by using an SSL checker. If you are using a CDN, check your encryption settings and make sure the redirects you set up on the server do not conflict with what your content delivery network enforces.
Step 3. Fix “The Response is not a valid JSON response” Message in WordPress
If you have carefully examined your WordPress website and noted all updates that have been recently made to it, you will be able to determine what has caused the “The response is not a valid JSON response” error message to appear when using the block editor or uploading media.
Unless your permalink structure is broken or there are any other serious issues that cause other errors on your website, you can temporarily switch to the classic editor if you absolutely need to publish a certain post as soon as possible. Install the Classic Editor plugin, which will replace the block editor upon activation. Once a post is published, you can resume the troubleshooting process.
Follow the instructions included in the previous section of this guide to address the issue you have identified. If your WordPress site address settings are correct, permalinks are working as expected, and you have ruled out all issues with SSL, mixed content, and competing redirects, deactivate your security solutions. If it doesn’t help, deactivate all plugins to see if a plugin conflict is at fault.
If nothing helped to identify the issue and you are unsure what is causing the “The response is not a valid JSON response” error message on your website, contact your web hosting support team for assistance. You may need a second pair of eyes which is completely normal. Moreover, support administrators will be able to check server logs which can speed up the troubleshooting process.
The WordPress block editor is a client-side application that uses REST API to communicate with the server and send data. Any interruption to the client-server communication will result in errors, including “The response is not a valid JSON response.” WordPress invalid JSON response errors can be caused by different issues, the most common of which are incorrect WordPress address settings, broken permalink structure, SSL errors, and conflicting redirects.
Sometimes, a WordPress site can be blocked by a security plugin or another solution used as a web application firewall. The best way to minimize the possibility of having requests sent from the admin dashboard blocked and save time troubleshooting errors while being fully protected from malicious traffic is by choosing the right security software.
There is a fine line between security and usability, but you do not need to choose between those. iThemes Security Pro is a WordPress security plugin that allows you to focus on daily tasks and be sure that your WordPress website is protected from all known vulnerabilities and security threats.
Kiki has a bachelor’s degree in information systems management and more than two years of experience in Linux and WordPress. She currently works as a security specialist for Liquid Web and Nexcess. Before that, Kiki was part of the Liquid Web Managed Hosting support team where she helped hundreds of WordPress website owners and learned what technical issues they often encounter. Her passion for writing allows her to share her knowledge and experience to help people. Apart from tech, Kiki enjoys learning about space and listening to true crime podcasts.