How to Solve “The response is not a valid JSON response” Error in WordPress?

The response is not a valid JSON response

I encountered this problem “Updating failed. The response is not a valid JSON response.” a little while ago when I was working on a new blog hosted on Google Cloud Platform.

You may get this error “The response is not a valid JSON response” while saving your post as a draft or publishing your post or page. Right?

Do not worry! I solved this error in my case, so you can too.

In this post, I am highlighting some solutions that work for most of the cases. I got all those the response is not valid JSON response fixes when I was searching to fix mine.

And I am also giving you the response is not a valid JSON response fix that worked for me, which is very easy and SEO friendly.

Without further ado, let’s get started.

Contents

  1. Why “the response is not a valid JSON response” error occurs?
    • Mixed Content Error in WordPress
    • Disable Block Editor
    • Set Permalinks Settings to Plain
    • Trial and Error Method
  2. How I Resolved the response is not a valid JSON response error.
    • How to Enable Apache mod rewrite?
  3. Conclusion
  4. FAQs

Why “the response is not a valid JSON response” error occurs?

You can get this error at the time of saving your content as a draft or publishing your content. Not only this but also you can not create a new post or page.

There are several reasons for this error to occur.

Let’s see the reasons as well as solutions respectively.

Mixed Content Error in WordPress

Because of not properly configuring your SSL certificate, mixed content error may occur on your blog. This is a common cause of the problem we’re concerned about in this article.

Let me make it simple for you.

You have an SSL certificate on your WordPress site and still, you’re serving some non-HTTPS URLs. Mostly, these HTTP URLs are dynamic.

By solving the mixed content error, “The response is not a valid JSON response” error may also be solved.

If you’re using any other SSL plugin like Cloudflare Flexible SSL then try deactivating the plugin.

How to Solve the Mixed Content Error?

To solve the mixed content error, install a plugin called Really Simple SSL.

  • Turn on Mixed content fixer
  • Turn on Use alternative method to fix mixed content

After performing these operations, try saving your post. The error should’ve gone by now.

Disable Block Editor

When I got this the response is not a valid JSON response error, I tried disabling the Block editor of WordPress and turned out to be a solution. But I did not want to let go of the Block editor, so I dug a little bit more deeper into this problem.

You can install the Classic Editor Plugin and activate it to disable the block editor. Then try saving your post. No error message! Right?

Here’s another fix for the response is not a valid JSON response error.

  • Go to Settings >> Permalinks
  • Click the radio button to select Plain
  • Click Save Changes

This is a simple solution that works most of the time.

But! This is not a practical fix for the response is not a valid JSON response error.

Why?

Look! Permalinks play an essential role in SEO. If your permalink looks like https://mywebsite.com/?p=076 for a post then, it is a bad signal for search engines. Rather having a post name in permalink is preferred.

Trial and Error Method

You can further use this method to find out what is wrong with your WordPress site. Sometimes, because of some conflicting plugins, the response is not a valid JSON response error occurs.

You can deactivate plugins one by one and test if the error is still there.

One more thing you can do is change your WordPress theme to default themes that came with WordPress installation. Check for the error.

If none of these works try to reset your WordPress installation.

Using this method, you can find out what is causing the error and eliminate the root cause.

How I Resolved the response is not a valid JSON response error.

First of all, some of the solutions that I’ve shared above worked for me. By setting up the permalinks to plain and disabling Block Editor, I was able to rectify the error.

But I was looking for a solution that does not hurt SEO and I love working with the Block Editor.

At the beginning of this article, I stated that the WordPress site, I was working on, is hosted on Google Cloud Platform (GCP). I set up a custom Apache server on GCP. And I forgot to run a simple command while configuring the server.

Because of inappropriate server configurationthe response is not a valid JSON response” error occurred.

Before going to how I solved it? Let’s take a look at why the error occurred?

So, basically like every other blog, I changed my permalinks to post name, and that updated the .htaccess file. Since I forgot to update my Apache rewrite engine, the URL rewrite was not working as expected. So, when I used the method with Set Permalinks to Plain, there was no such error message because I wasn’t rewriting the default URLs.

After discovering the culprit, it was pretty easy to solve “the response is not a valid JSON response” error.

If you run a VPS server then this method may solve the problem.

How to Enable Apache mod_rewrite?

Let’s see how I solved the “the response is not a valid JSON response” error.

First, I established an ssh connection with my Compute Engine. And then I activated the mod_rewrite, which was not enabled by default with my Apache2 installation.

$ sudo a2enmod rewrite

Next, I restarted my Apache2 server.

$ sudo systemctl reload apache2

After performing these operations, my problem was solved. You can do exactly the same I did to enable mod_rewrite.

How to Enable Apache mod_rewrite in Cpanel?

For those of you, who do not use VPS and are using shared hosting, you probably do not need this method. But, if you want to give it try, then follow the steps below.

  • Inside your CPanel, got to Terminal.
  • You will see your terminal like this –

Then use the commands (above) to enable mod_rewrite. This method is for you if you have an Apache server.

Conclusion

I hope one of these methods worked for the “the response is not a valid JSON response” error you’re facing.

If it worked for you, let me know in the comment section below.

And if you like this article, feel free to share it.

FAQs

Why “the response is not a valid JSON response” error occurs?

You can get this error at the time of saving your content as a draft or publishing your content. Not only this but also you can not create a new post or page.

There are several reasons for this error to occur.

Let’s see the reasons as well as solutions respectively.

How to solve the Mixed Content Error?

To solve the mixed content error, install a plugin called Really Simple SSL.

1. Turn on Mixed content fixer

2. Turn on Use alternative method to fix mixed content

How to Set Permalinks Settings to Plain?

1. Go to Settings >> Permalinks

2. Click the radio button to select Plain

3. Click Save Changes

How to Enable Apache mod_rewrite?

1. sudo a2enmod rewrite

2. sudo systemctl reload apache2

«
»