How to Fix the Frustrating "Invalid JSON Response" Error in WordPress
Few things are more aggravating than seeing an angry red error message pop up when you‘re trying to work on your WordPress website. If you‘ve encountered the "invalid JSON response" error while creating content or uploading media in WordPress, you know firsthand how disruptive it can be.
This nasty notice typically appears after clicking the Update or Publish button, with the full message being something like: "Updating failed. The response is not a valid JSON response." It prevents you from saving your work and can really throw a wrench in your content creation process.
But don‘t worry! While this error may seem scary, it‘s usually not too difficult to fix. By methodically working through some straightforward troubleshooting steps, you can squash this error message and get back to business on your WordPress site.
In this post, we‘ll explain what causes the invalid JSON response to rear its ugly head and walk you through how to definitively exterminate this pest in a few different ways. Grab your debugging hat and let‘s dive in!
Understanding JSON and the Invalid JSON Response Error
Before we start debugging, it helps to understand a bit about what‘s going on behind the scenes when this error occurs. JSON, which stands for JavaScript Object Notation, is a format used to transmit data between a server and web application. Think of it like a shared language that allows different parts of your WordPress site to communicate.
When you‘re working in the WordPress editor, there‘s constant back-and-forth communication happening between the editor and your website‘s server. The editor sends "requests" and expects "responses" back from the server in valid JSON formatting.
If the editor sends a request but doesn‘t get the proper JSON response back that it‘s expecting, that‘s when you‘ll see the "invalid JSON response" message. It‘s the editor‘s way of telling you that the server isn‘t responding in the way that it should.
Most commonly, you‘ll encounter the invalid JSON response when working in the new WordPress block editor (aka Gutenberg) or when uploading media files. It typically appears after clicking the Update, Publish, or Save button.
There are a number of different factors that can disrupt the proper JSON "dialogue" between the editor and server. Plugin conflicts, SSL certificate issues, improper permalinks, and firewall settings are some of the most frequent culprits.
Fortunately, by working through a progression of troubleshooting steps, you can usually zero in on the source of the issue and squash the invalid JSON bug pretty quickly. Let‘s take a look at how to do just that.
How to Troubleshoot and Fix the Invalid JSON Response Error in WordPress
Since a number of different issues can trigger the invalid JSON response error, it helps to take a systematic approach to debugging. We‘ll walk through some steps you can take to troubleshoot, in the order that you should try them.
While you hopefully won‘t have to try every single fix, working through this list in progression will help you locate the source of trouble and return to site creating without too much hassle.
1. Re-save your WordPress permalinks.
One of the most common causes of the invalid JSON response error is a problem with your WordPress permalink settings and .htaccess file. Luckily, this has a quick and easy fix.
First, visit the Permalinks settings screen at Settings > Permalinks in your WordPress dashboard. You don‘t need to change any permalink settings. Just scroll to the bottom and click the Save Changes button. This will flush the rewrite rules and update your .htaccess file.
If permalinks were the culprit, simply re-saving them should remove the error and get your site humming along once again. Visit the post editor and check if this fixed the issue.
As an added measure, you can completely regenerate the .htaccess file by renaming or deleting the existing one in your site‘s root directory via FTP or hosting file manager. Then repeat the process of re-saving your permalinks in the WordPress dashboard to generate a fresh copy of the file.
For most WordPress sites, fixing permalinks and .htaccess will resolve the invalid JSON response error. But if you‘re still seeing it, let‘s continuing sleuthing for other possible causes.
2. Check your WordPress site URL settings.
Another common cause of the JSON formatting error is incorrect settings for your WordPress site URL. If you recently migrated your site to HTTPS/SSL or changed domains, it‘s possible that your URLs are set improperly.
Go to Settings > General in your WordPress admin dashboard. Look at the WordPress Address and Site Address fields. In the vast majority of cases, the URL should be identical in both fields.
Also, make sure that both URLs start with https:// if you have an SSL certificate installed on your site (which you should!). Having URLs that start with http:// on an HTTPS site is a recipe for JSON response errors.
Click the Save Changes button at the bottom of the page to update your site URL settings if you made any changes.
3. Resolve mixed content warnings.
If your WordPress site loads over HTTPS, then ALL resources on the page (images, scripts, etc.) must load over HTTPS as well. If some resources still load over HTTP, it can trigger "mixed content" warnings and lead to JSON response errors.
First, make sure your SSL certificate is properly installed and configured. SSL issues are a frequent source of mixed content errors.
If you‘re using a plugin to force HTTPS on your site, make sure any "HTTP/HTTPS" or "site URL" settings are properly enabled and configured to fix mixed content issues.
It‘s also a smart idea to scan your site for potential mixed content issues using a free tool like SSL Check or Why No Padlock?. These scanners will reveal specific mixed content errors on your site that you can go correct.
4. Temporarily disable your security plugins and firewall.
WordPress security plugins and web application firewalls (WAFs) are important for protecting your site. But sometimes, the security rules can inadvertently block valid requests and cause the JSON response error.
If you use a security plugin like WordFence or Sucuri, try temporarily disabling it and then testing if you still see the error. If the error goes away, you‘ll know that a setting in the security plugin was likely the cause.
You can try adjusting the settings of the security plugin, disabling specific firewall rules, or reaching out to the plugin support team for further assistance. The key is finding a balance of strong security settings without blocking legitimate requests.
5. Try activating and deactivating the Classic Editor plugin.
While it may sound strange, some users report fixing the invalid JSON response error by simply activating and deactivating the Classic Editor plugin. It only takes a couple minutes to test this.
First, install the official Classic Editor plugin from the Plugin Directory. Activate it, and use the plugin settings under Writing to set the default editor for all users to the Classic Editor. Save the settings.
Then, change the default editor back to the Block Editor (Gutenberg). Finally, deactivate the Classic Editor plugin completely.
Visit the editor screen and check if the JSON error message still appears. If not, it seems the old "turn it off and back on again" trick did the job!
6. Systematically deactivate all WordPress plugins.
If none of the previous steps have killed off the JSON response error, there‘s a good chance that a plugin conflict is the root cause. With 50,000+ free plugins in the WordPress directory alone, the number of potential conflicts is mind-boggling.
You‘ll need to systematically deactivate your plugins one-by-one in order to sniff out the offending extension. It‘s a bit tedious, but it works.
Start by deactivating ALL your plugins. Visit the post editor and check if the JSON error is gone. If it is, you know that one of the deactivated plugins was causing the issue.
Now re-activate ONE plugin at a time, visiting the post editor each time to check for the error. When the invalid JSON response rears its ugly head again, you‘ve found the incompatible plugin!
At this point, you can either find an alternative plugin that provides the same functionality without breaking your site, or reach out to the plugin developer and ask them for help resolving the incompatibility.
7. Upload media directly to the Media Library.
Sometimes the invalid JSON response error only appears when trying to upload images or other media through the block editor. If that‘s the case, you can usually get around it by uploading media directly through the classic Media Library instead.
When adding an Image block, click the Media Library button to open it up instead of uploading the file directly through the Image block interface. Select or upload the image you want to use.
This will load the traditional Media Library interface rather than the editor-specific media uploader. In many cases, this resolves the JSON response error when working with media.
8. Check the browser console and error logs.
If you‘ve followed the troubleshooting steps so far and are still hitting the JSON response wall, it‘s time to attempt some deeper debugging.
In your browser, open up the Developer Tools and check the Console tab for any JavaScript errors that occur when loading or updating content. Look for error messages that mention "admin-ajax.php" or "REST API" as these can point to the source of the JSON response issue.
You can also check for REST API errors from your WordPress dashboard under Tools > Site Health. Look for errors under the label "The REST API encountered an unexpected result."
Finally, activate WordPress debugging and check your error logs (typically found in /wp-content/debug.log) for clues about what‘s causing the invalid JSON response error. You may need to consult with a developer to make sense of the log file messages and trace the issue further.
9. Use the Classic Editor plugin as a fallback.
If you‘ve exhausted all other troubleshooting options and still can‘t resolve the JSON response error, you can always install the Classic Editor plugin as a temporary fallback measure.
While you‘ll lose the advanced content creation features of the block editor, using the Classic Editor will at least allow you to publish content on your site while you continue debugging the JSON error.
Remember, this isn‘t a long-term fix, but rather a stopgap measure in case you need to push content live and can‘t wait for a proper resolution to the block editor issues.
Squash the Invalid JSON Response Error for Good
Dealing with WordPress errors is never fun, but the dreaded invalid JSON response error doesn‘t have to ruin your day. With patience and systematic troubleshooting, you can almost always root out the cause of the issue and restore your site to normal.
Start by fixing permalinks, validating URL and SSL settings, force-updating the .htaccess file, and deactivating security plugins. If you‘re still seeing the error, try the Classic Editor activation/deactivation trick, selectively disable plugins, and upload media through the core Media Library.
If you really get stuck, don‘t despair! Check for JavaScript and PHP errors in your browser console and WordPress logs. Consider using the Classic Editor plugin as a temporary workaround while you dig deeper.
By checking off fixes in a methodical way, you‘ll almost certainly be able to send this unwelcome error message packing and get back to crafting content in WordPress. Stay patient and persistent and you‘ll emerge victorious!
