WordPress: Fix Updating failed. The response is not a valid JSON response

|
Last Updated:
|
|

In this tutorial, I will show you a quick fix to the common WordPress error, Updating failed. The response is not a valid JSON response related to default Gutenberg editor.

Note that I experienced this issue while adding a specific block of text on WordPress post. Whenever i tried to save the post after adding that block, it always resulted in the annoying message;

Updating failed. The response is not a valid JSON response

Fix Updating failed. The response is not a valid JSON response

Fix Updating failed. The response is not a valid JSON response

If you paste this specific keyword on the Google search bar, you will get millions of results on how to fix this issue.

I tried to implement most of the solutions such as;

  • Updating the WordPress permalinks
  • Using the Classic editor instead. This couldn’t my choice even if it could solve the issue since it really sucks, imho!
  • I dont know, fix SSL redirect issues…
  • Regenerate WordPress .htaccess file
  • Check the themes and plugins
  • Check site health
  • and the endless Internet suggestions…

I ransack the site configurations up and down but I never found out any issue on my backend server/WordPress configs.

So, I am using Cloudflare!

It turns out that a specific Cloudflare special managed rules were blocking some requests generated whenever I hit Save button after adding that specific block on WordPress post.

How did I find out about Cloudflare blocking this request?

Well, on the WordPress post page;

  • open the browser developer tools using Ctrl+Shift+I. It should work on both Chrome and Firefox.
  • Head over to the Network tab;

As you can see from my screenshot below, some requests with specific query is returning Forbidden Error 403 code.

Fix Updating failed. The response is not a valid JSON response

Drilling down further by clicking that specific line with 403 status to the headers;

Request Headers tab, path: /wp-json/wp/v2/posts/13239 and Query String: ?_locale=user

Fix Updating failed. The response is not a valid JSON response

On the Preview tab, there was this message;

Please enable cookies.

Sorry, you have been blocked

You are unable to access kifarunix.com

Why have I been blocked?

This website is using a security service to protect itself from online attacks. The action you just performed triggered the security solution. There are several actions that could trigger this block including submitting a certain word or phrase, a SQL command or malformed data.

What can I do to resolve this?

You can email the site owner to let them know you were blocked. Please include what you were doing when this page came up and the Cloudflare Ray ID found at the bottom of this page.

Cloudflare Ray ID: 7213e53f69xxxxxx • Your IP: xx.xx.xx.xx • Performance & security by Cloudflare

On the Response tab, I could see some cookies are blocked!

<script>
  if (!navigator.cookieEnabled) {
    window.addEventListener('DOMContentLoaded', function () {
      var cookieEl = document.getElementById('cookie-alert');
      cookieEl.style.display = 'block';
    })
  }
</script>

So, I contacted Cloudflare support who pointed me to update my firewall rules and allow the request accordingly using the Ray ID given on the preview tab.

So head over to Cloudflare web interface and filter for the Security > Overview and filter the events related to the specific Ray ID given, source IP or even the paths on the request headers.

Sample screenshot.

Fix Updating failed. The response is not a valid JSON response.

As you can see, the block contained some specific keywords or whatever it is that are seen by Cloudflare firewall rules as malicious and is thus blocked by the default managed rules.

So, in order for me to proceed to save my posts, I had to write a rule that checks for my source IP and the specific keywords on the request path and set the firewall to bypass the managed rules.

The specific managed rule number 100005 is under the Cloudflare Specials rules group.

Thus, this is the rule to bypass this at least from my source IP.

Security > WAF > Firewall Rules

My sample rules;

Fix Updating failed. The response is not a valid JSON response.

Save and it should be enabled.

Fix Updating failed. The response is not a valid JSON response.

You now be able to save your post with no error, Fix Updating failed. The response is not a valid JSON response.

If you are using Cloudflare, then that is it on how to fix WordPress Fix Updating failed. The response is not a valid JSON response error.

That marks the end of our tutorial on how to fix WordPress Fix Updating failed. The response is not a valid JSON response.

Other Tutotials;

Protect WordPress Against Brute force Attacks Using Fail2ban

Restrict Access to WordPress Login Page to Specific IPs with libModSecurity

SUPPORT US VIA A VIRTUAL CUP OF COFFEE

We're passionate about sharing our knowledge and experiences with you through our blog. If you appreciate our efforts, consider buying us a virtual coffee. Your support keeps us motivated and enables us to continually improve, ensuring that we can provide you with the best content possible. Thank you for being a coffee-fueled champion of our work!

Photo of author
koromicha
I am the Co-founder of Kifarunix.com, Linux and the whole FOSS enthusiast, Linux System Admin and a Blue Teamer who loves to share technological tips and hacks with others as a way of sharing knowledge as: "In vain have you acquired knowledge if you have not imparted it to others".

Leave a Comment