Let’s say you've been editing your WordPress site and just created a new post in the Gutenberg block editor. Next, you’d like to save changes and publish it. Suddenly, an orange banner appears over your screen with the following disturbing message:
“Updating failed. Error message: The response is not a valid JSON response.”
Now, you can’t save or publish the post. If you move away from the page, you may lose all your stored changes and have to start from scratch. This is a concerning situation obviously.
Understanding and fixing the "not a valid JSON response" WordPress error
So, what causes the JSON response WordPress error?
And how can you fix it? Let's take a deeper look the answers for these important questions.
Understanding how the WordPress block editor works
Before diving into what causes the “not a valid JSON response” WordPress error, let’s first explore how the block editor works.
The Gutenberg block editor, first introduced in 2018, uses the WordPress REST API to establish communication between the server and itself. That’s because it’s a client-side application without direct access to the database.
For any changes you make to be stored, the block editor must use the REST API to create and update posts using the JavaScript Object Notation (JSON) format.
Using the JSON format, the block editor creates a representation of the post in a way that the WordPress REST API predetermines. When you click the Update button on the Gutenberg editor, it sends a request through the REST API to the server and receives a JSON response that updates the post.
Overview of the “not a valid JSON response” WordPress error condition
Whenever an attempt to update a post in the manner described above fails, you may encounter the "not a valid JSON response" WordPress error. It can also appear when you attempt to upload media or content to a Gutenberg block directly.
Here’s what you may see:
Another example of what you may see is the following:
Whenever you see this error, it implies a problem with the block editor and server communicating. It could be that the editor failed to send a request to the server or receive a response, or the response was in an invalid JSON format.
Fixing this problem requires reestablishing a connection with the server. To identify the particular problem facing your particular setup, you may have to identify and fix anything preventing a connection to your server.
Working vs. error condition: JSON response examples
You may encounter an invalid JSON response error in your WordPress website for many reasons. Here are some common examples of JSON response errors and actions you can take to resolve them:
Incorrect website address settings
Poor website address configurations are often the most common reason for invalid JSON response errors. Using the wrong address is common, especially after migrating to a new host or cloning your website.
But fixing incorrect website address settings is also easy. To do so:
- Go to your dashboard and then Settings > General.
- Make sure your URLs are accurate. Check for variations in spelling and any additional punctuation marks. If you notice a problem, correct it.
- Next, check the protocol. If you use a Secure Socket Layer (SSL) certificate, ensure your addresses use https:// instead of http://.
- Save your changes to apply them across your website.
Alternatively, you can change these settings from the WordPress database directly or by changing the wp-config.php file. This option isn’t always necessary unless your URLs are hard coded to the file. If that’s the case, no changes to your General settings will take effect until you reconfigure that file.
To reconfigure wp-config.php:
- Use your File Transfer Protocol (FTP) program or your host's cPanel or equivalent tools to open the wp-config.php file.
- Look for the code define (‘WP_SITEURL and define ( ‘WP_HOME.
- Each of these snippets will come with a URL. Ordinarily, the two URLs are identical. If you notice an issue with these URLs, you can edit or remove them. That way, your website defaults to the WordPress and site URLs defined in your General Settings.
Secure Sockets Layer (SSL) and mixed content issues
An SSL certificate is an excellent way to make your website trustworthy and credible. But it only offers security when it forces every resource in your website to load through a secure protocol.
If some resources load over Hypertext Transfer Protocol (HTTP), this may cause a “mixed content” error and may also throw an invalid JSON response error.
If you fixed the URLs in the General Settings to use Hypertext Transfer Protocol Secure (HTTPS), you should no longer have mixed content warnings. However, if you’re facing extra issues, you can fix them with a plugin:
A plugin like Really Simple SSL comes with an option to fix mixed content errors.
Please note that you can only use HTTPS with a valid SSL certificate. If not, you can’t use the HTTPS protocol, which may cause further problems. Instead, use a valid SSL certificate or revert to the HTTP protocol.
Issues with Permalinks
Another issue that is relatively easy to fix is the Permalink Structure. These are the unique URL links each page and post has, which may sometimes change:
To fix the Permalinks:
- From the WordPress Admin Dashboard, go to Settings > Permalinks.
- Determine if the Permalink Settings are in order. If not, select an option that suits your website, or create a custom structure.
- Once you’ve selected an option, save the changes.
Refresh your editor and check if you’ve fixed the error.
Issues with the .htaccess file
Sometimes, the .htaccess file, which allows you to make independent changes to your website’s directories, can cause invalid JSON response errors. If the file is corrupted or broken, you can delete it and force WordPress to remake it to resolve the error.
To make a new .htaccess file:
- Using the control panel or FTP, open your server and locate the file in your root folder.
- Download the file as a precaution. Then, delete the server’s copy of the file.
- Update your Permalink Settings and save the changes.
Firewall and security setup issues
Using firewall software can sometimes cause the “not a valid JSON response” WordPress error if restrictions set by security software prevent a connection with the server. The issue may sometimes be with your Web Application Firewall (WAF) or WordPress security plugin.
For instance, Nexcess uses the ModSecurity WAF to monitor incoming connections. It comes with a set of configured rules that every request must check against before accessing the server. This setup prevents potential network attacks on your server.
Once a rule is triggered, ModSecurity blocks the connection and returns an error message. Below are some examples of rules in ModSecurity:
You can also opt for a WAF that comes with your Content Delivery Network (CDN) subscription. For example, Cloudflare uses a WAF with managed rulesets that filter out multiple malicious requests before they can compromise your server.
WAF plugins like Wordfence and Solid Security Pro can provide enhanced security with their own secure rulesets.
Modern security solutions are often optimized, but sometimes, false positives can trigger these rules. Once triggered, you may receive a “not a valid JSON response” WordPress error as you update a post or a page from the administrator dashboard. This error message may recur until you fix the issue that’s causing a false positive.
You can address this challenge in several ways:
- First, deactivate any WordPress security plugin or WAF, including the Cloudflare WAF. Often, this resolves the issue.
- If it does, identify the trigger that blocked the server connection. You may have to whitelist some requests and correct others.
- If the issue persists, reach out to the Nexcess customer support team. A qualified technician will check the server logs to see if ModSecurity might be at fault.
Avoid JSON errors with managed WordPress hosting from Nexcess
“Not a valid JSON response” errors may result from different sources, but the most common are incorrect website address settings, issues with SSL and redirect conflicts, and broken Permalink Structures.
Build your WordPress platform with Liquid Web in your corner
Get hosting optimized for WordPress from a provider with 25+ years of experience.
You must reestablish a successful connection between the browser and the server to fix the JSON error and use the Gutenberg block editor. You can troubleshoot the underlying issue using these instructions and restore your lost functionality as soon as possible.
Want to skip all the technical nitty-gritty? Check out the benefits that come with our managed WordPress hosting plans from Nexcess and focus on growing your business while experts handle your website. Read our Nexcess hosting and Nexces Client Portal guide or contact our support staff to get started.