How To Fix Invalid JSON Error In WordPress: 10 Quick Ways

It seems you’ve recently encountered the “The response is not a valid JSON response” or “Updating failed. The response is not a valid JSON response?” error in your WordPress editor and are looking for a solution. You’ve landed on the right post.

In this post, we’ll explore what causes this error and outline effective methods to fix it. So, without further delay, let’s get started.



What causes an Invalid JSON Response Error in WordPress?

Before jumping to the reasons that cause an Invalid JSON Response Error in WordPress, let’s understand why it triggers in the first place.

The error message generally pops up when you are working in the WordPress Block Editor and also it appears when you trying to add a media file directly into a block.

Why does the error “ an Invalid JSON Response Error” even trigger in WordPress?

The answer is when you edit a page or post, WordPress continuously communicates with the server to save the changes you have made.

This communication happens using JavaScript, which is responsible for sending data in a format called JSON.

During the communication, if something goes wrong such as there is an issue with JavaScript code or a connection issue with the server, WordPress will not get the proper response and as a result lead to this error.

Note: Before trying to fix this error, you should back up your site first because, if anything goes wrong, you can easily get back your website like it was before.

Common Reasons that cause Invalid JSON Response Error in WordPress

The causes of the “Invalid JSON” error in WordPress typically include the following:

1. Incorrect URL Settings:

   – If the site URL or WordPress URL settings are incorrect (e.g., mismatched URLs or HTTP/HTTPS inconsistencies), the editor might struggle to connect to the server, causing the error.

2. Broken Permalinks:

   – Permalinks are the URLs of your posts and pages. If these are broken or not configured correctly, WordPress may fail to generate proper JSON responses, leading to the error.

3. Theme or Plugin Conflicts:

   – Certain themes or plugins might interfere with the editor’s ability to communicate with the server. This can be due to outdated code, conflicts between plugins, or issues in JavaScript execution.

4. Server Configuration Issues:

   – Misconfigurations on the hosting server, such as improper SSL settings, incorrect server permissions, or firewall settings, can block the editor from receiving the expected JSON response.

5. .htaccess File Corruption:

   – The .htaccess file controls how URLs are processed by your server. If this file is corrupted or misconfigured, it can prevent WordPress from correctly handling requests, leading to JSON errors.

6. Rest API Issues:

   – WordPress relies on the REST API to communicate with the server. If the REST API is disabled, blocked, or malfunctioning, it can prevent WordPress from receiving valid JSON responses.

7. JavaScript Errors:

   – Errors in the JavaScript code used by WordPress or third-party plugins can cause issues in sending or receiving JSON data, resulting in the error.

8. SSL Certificate Problems:

   – If the SSL certificate is not properly configured, or there are mixed content issues (using both HTTP and HTTPS), it may disrupt communication between the editor and the server, causing JSON errors.

9. Firewall or Security Plugin Restrictions:

   – Firewalls or security plugins may block necessary requests between the editor and the server, causing the editor to fail in retrieving valid JSON responses.

Understanding these potential causes can help diagnose and fix the “Invalid JSON” error in WordPress effectively.


WPOven

How to Fix the WordPress Invalid JSON Response Error?

Now you know the meaning of an Invalid JSON Response Error and the reason that causes it, let us check out some methods that can help you fix it.

Below, methods are provided, starting from basic troubleshooting steps to advanced ones, so that the initial methods generally fix the issue and you do not need to follow the other methods.

1. Check the URL settings in WordPress

One of the most common reasons that triggers an Invalid JSON Response Error is using the wrong URL settings.

By any chance, if you have mistakenly used “HTTP” instead of “HTTPS”, it can create a mixed content issue, which translates that your browser is trying to load both HTTP and HTTPS content, resulting in this error message.

But it can be easily fixed by simply checking the WordPress Address and Site Address settings of your WordPress site. To do this,

  • Go to your WordPress dashboard and Navigate to Settings → General
  • Now, Go to URL Settings, and make sure that both the WordPress Address (URL) and Site Address (URL) are set to “HTTPS” if your site uses an SSL certificate.
Checking URL settings in WordPress
Checking URL settings in WordPress
  • If you found any mistakes and corrected them, click on the “Save Changes” button.
  • Once done, try to edit a blog post again and also try adding new blocks or saving the post to see if the error is resolved.

Permalinks, or permanent links, are unique web addresses for each page or post on your website.

However, if you configure the permalink settings incorrectly, it can cause issues where the WordPress editor doesn’t receive a valid JSON response, resulting in an ‘Invalid JSON response’ error.

checking WordPress site's permalink
checking WordPress site’s permalink

 To fix this, 

  • First, Log in to your WordPress dashboard.
  • Navigate to Settings → Permalinks
  • Now check permalink settings and make sure the right permalink structure is selected. If you are a beginner and do not know which setting to use, choose the default option.
  • After making the corrections and selecting the correct permalink settings, click on the “Save Changes” button and try to edit the post or page to check if the error is resolved.

3. Delete and Regenerate .htaccess file

In WordPress, the .htaccess file is responsible for managing and configuring SEO-friendly links, what we also call permalinks, for your site.

Every time a new URL is generated, it is automatically updated in the .htaccess file. This also happens when you change permalink settings in WordPress and click the ‘Save Changes’ button.

However, if the links are incorrectly configured or if there are issues during the update, the .htaccess file might not be updated properly, which can result in a ‘JSON invalid response’ error.

 If this is causing the issue, you can fix it by deleting the .htaccess file and forcing WordPress to regenerate it. Here’s how you can do it.

1. Connect to the website to access files via an FTP client (like FileZilla) or the file manager in your WordPress hosting dashboard.

2. Once connected, look for the .htaccess file in your website’s main (root) folder. This file controls how URLs are managed.

3. Download a copy of the .htaccess file to your computer, it will work as a backup in case you need it later.

Downloading .htaccess file from the server for backup
Downloading .htaccess file from the server for backup

4. Delete the .htaccess file from the server. Don’t worry, WordPress will create a new one for you.

5. Update Permalink Settings:

   – Go to your WordPress dashboard.

   – Navigate to **Settings → Permalinks**.

   – Make sure the permalink structure you want is selected.

   – Click the **Save Changes** button. This will automatically create a new, clean .htaccess file.

6. Now go back to your site and see if the error message “Updating failed. The response is not a valid JSON response” is gone.


4. Deactivate plugins and switch to a default theme

If none of the above methods work, check your theme and plugins. Sometimes, a buggy theme or faulty plugin can trigger such errors.

Figuring out the theme is relatively easy; you can temporarily switch to a default theme to see if the error persists. 

However, debugging WordPress errors can be challenging because each plugin adds its complexities.

With so many plugins available, there are many possible reasons for errors like ‘invalid JSON response.’ Each plugin might affect your site in different ways, making it hard to determine what’s wrong. 

However, this doesn’t mean you can’t figure out the faulty one. The best approach is to deactivate all plugins at once.

Deactivating WordPress plugins in bulk
Deactivating WordPress plugins in bulk

Here is how you can do it,

1. Go to your WordPress dashboard and Navigate to Plugins → Installed Plugins.

2. Check the box at the top of the list to select all your WordPress plugins.

3. From the **Bulk Actions** drop-down menu, select **Deactivate**.

4. Click the **Apply** button to deactivate all selected plugins.

If the error persists after deactivating all plugins, then plugins are not the main issue, and you can reactivate them.

In case, deactivating the plugins resolves the ‘invalid JSON response’ error, you’ve identified that a plugin is causing the problem. 

To find the faulty plugins, reactivate them individually and check the editor after each activation.

If the error returns after activating a particular plugin, you’ve found the problematic plugin. You then have two options: either remove the faulty plugin completely or find an alternative plugin to use.


5. Try using Classic Editor

Based on feedback from many users, it has been observed that switching back to the Classic Editor often resolves the ‘invalid JSON response’ error.

This issue has become more prevalent since the upgrade from the Classic Editor to the Block Editor. Therefore, you should also try switching back to the Classic Editor; it will take only 10 minutes.

Note: Be cautious while switching from the new Block Editor to the old Classic Editor in WordPress. Because it might make certain changes and alterations to the pages or posts, this process can also affect the formatting and layout of any previously edited content using the Block Editor.

To avoid such mishaps, you should take a precautionary step by adjusting a setting in the Classic Editor before making the switch, to ensure your site remains secure and stable.

Here’s how you can install the classic editor 

1. Just like any WordPress plugin, installing a classic editor is the same, i.e. Go to the WordPress dashboard > Plugins > Add New > Search for “Classic Editor” > Install > Activate.

2. Now After activation, go to Settings > Writing

  • In the settings, find the option to select the default editor.
  • Use the drop-down menu to select **Classic Editor** as the default for all users.
Switching to Classic Editor in WordPress
Switching to Classic Editor in WordPress
  •    Click on the Save Changes button to apply this setting.

3. Now, Try creating or editing a new post to see if the issue is resolved.

4. If you wish to return to the Block Editor, go back to **Settings → Writing**.

  • Use the drop-down menu to select **Block Editor** as the default editor.
  •    Click “Save Changes” again.

5. After switching back, try creating or editing another post to ensure everything is working correctly.


6. Check Security firewall settings or Rules

If you have set up strong or aggressive firewall rules, such as using Cloudflare CDN to protect your WordPress site from spam.

It might interfere with the connection between the WordPress editor and your server. This could cause the error: ‘Updating failed. The response is not a valid JSON response.

To fix this you can do the following, steps:

  1. Temporarily Disable the Firewall to check if this is causing the error

Turn off your WordPress firewall service temporarily and check. If the editor works after doing this.

  2. If the Firewall is at the Host Level:

If your firewall is provided and managed by your hosting provider, contact them to check it from their end. If so, ask them to whitelist the WordPress editor so it doesn’t trigger the firewall and cause errors.

  3. Options for Firewall Plugins:

By any chance if you are using any firewall plugin and if it is causing the issue, consider switching to a different firewall plugin.

Also, you can contact the plugin’s developer to help in resolving the issue.


7. Utilize the Inspect Element tool to debug the log

If you are sounded technically advanced WordPress user, you can try to look deeper into what’s going wrong by using the Inspect Element tool to check out the debug logs.

All you have to do is,

  • Open Chrome press F12 or right-click on your page and select “Inspect” to open Developer Tools.
  • Go to the “Network” tab. Here, you can monitor all the network requests made by your site.
  • Select “FETCH/XHR” to filter and view Ajax requests specifically. This helps you see if there are any problems with the REST API, which is essential for your WordPress site to function correctly.
Utilize the Inspect Element tool to debug the log
Utilize the Inspect Element tool to debug the log

You can check for REST API issues directly from your WordPress dashboard. To do this:

  • In your WordPress dashboard, click on Tools, then select Site Health.
The REST API encountered an unexpected result message
The REST API encountered an unexpected result message
  • Once you’re there, look for a message that says something like “The REST API encountered an unexpected result.” This message can help you understand if there’s a problem with the REST API on your site.

This is a simple way to see if something is wrong with the REST API, which is important for how your WordPress site works.


WPOven Dedicated Hosting

8. Check WordPress Debug WordPress Logs

Apart from Developer Tools, you can also check WordPress logs that can help you out of the possible issues causing the error.

But before that, you have to enable WordPress Debug log first, since it is not enabled by default. To do this, all you have to do is, just add the following code snippet to the wp-config.php file.

define( ‘WP_DEBUG’, true );

define( ‘WP_DEBUG_LOG’, true );

After you add the code, WordPress will keep track of any errors in a file called debug.log. You can easily find this file in the /wp-content/ folder by using an FTP client such as FileZilla.

When you look at this error log, it can provide you with all the details about what’s causing the “invalid JSON Response Error” and you are easily able to fix it.


9. Upload Media files via the Media Library

If you encounter the error ” Updating failed. The response is not a valid JSON response” while uploading media files directly via Block Editor. You can try uploading via the Media Library Instead.

When you insert an image block, choose the “Media Library” option.

Uploading Media files via the Media Library
Uploading Media files via the Media Library

Then, pick the file you want to use and click the “Select” button.

Selecting the media file to upload in WordPress
Selecting the media file to upload in WordPress

This should help fix the error temporarily, but very helpful for those who are in the middle of writing a post and other methods haven’t worked.

Note: One thing you should keep in mind is that the naming of the image file should not contain any special characters (like symbols or non-English letters), or else it might cause the error “The response is not a valid JSON response.”

To avoid this issue, make sure your image file name is only in English letters and can have numbers and symbols like hyphens. After renaming your images correctly, try uploading them again to see if the error is fixed.


10. Get Expert Assistance

If none of the above methods work for you, the last thing you can do is contact your web hosting provider, especially if they specialize in WordPress hosting.

They have a WordPress technical support team that can usually help you resolve any issue related to WordPress or any technical issue related to your website.


Conclusion

The invalid JSON response error can be very irritating and frustrating.

But the best part is that fixing it isn’t troublesome and doesn’t require much technical knowledge. Generally, this error happens due to aggressively configured firewalls or incorrect permalinks. Fixing these issues can usually resolve the problem, but if not, we’ve already mentioned all the possible solutions you can try.

Also, let us know which method worked for you in the comments section.


Leave a Reply

Your email address will not be published. Required fields are marked *