The Fix for “Publishing failed. Error message: The response is not a valid JSON response.”

I was a Gutenberg early adopter, and – after all the doom and gloom – turns out it’s a pretty nifty piece of kit!

But last weekend I hit the Publish button on a new blog post, and I got this error message:

Publishing failed. Error message: The response is not a valid JSON response.

Initially I thought there might be a weird, non-ASCII character in my content, because I had copied and pasted some code. So I removed the content, hit Publish again, this time no problem. Then I manually wrote a few paragraphs, and hit Update, whereupon I got this error message:

Updating failed. Error message: The response is not a valid JSON response.

What the heck is going on!?

I did some quick searching, and it turns out that a few people have bumped into this issue, but no one seemed to have a solution. Some said hosting security settings, others said plugin conflicts, still others said it was a Gutenberg bug and just wait for the next release.

With no obvious culprit and no obvious solution, I decided to debug it myself. I went through the standard procedure of reducing complexity:

  1. Ensure everything is up to date
  2. Disable plugins
  3. Change theme to basic WordPress theme
  4. Reinstall WordPress
  5. Reset Permalinks
  6. Remove .htaccess file

Still no luck! How is this possible? Perhaps I really did need to wait for the next WordPress release…?

While I was accessing the filesystem to remove the .htaccess file, I noticed that there was also a .user.ini file, which was created by the Wordfence plugin when optimizing its firewall. The file contained the following code:

; Wordfence WAF
auto_prepend_file = '/home/accountname/public_html/wordfence-waf.php'
; END Wordfence WAF

It seems that even with the WordFence plugin deactivated, the Wordfence firewall was still in place via this file. As soon as I removed the .user.ini file, I could publish and update again!

So that’s the cause. But we still need a solution. If you’ve come across this issue, let me know how you resolved it. In the meantime, I will continue testing and see if I can ensure Gutenberg and Wordfence play nice together.

About the author

Pretium lorem primis senectus habitasse lectus donec ultricies tortor adipiscing fusce morbi volutpat pellentesque consectetur risus molestie curae malesuada. Dignissim lacus convallis massa mauris enim mattis magnis senectus montes mollis phasellus.

6 thoughts on “The Fix for “Publishing failed. Error message: The response is not a valid JSON response.””

  1. Hi

    That’s very strange. I was making a custom theme right now and I realized that the issue was caused by accidentally putting an HTML comment inside the functions.php file. Once I removed it, things went back to normal.

    But thanks

    Reply
    • Ashkan – Thanks for posting for your comment…..I found some html code in my functions.php that I forgot to delete. Deleted the html code, saved, and now my pages are loading with no error…Thank you!

      Reply
  2. Hi, thank you for the info. Deleting the .htaccess file solved the problem for me. wondering if this file isn’t necessary for security or anything else?

    Reply
  3. I had this issue which was driving me crazy!

    After several YT videos, most of them pointing out the “install Classic Editor plugin” solution, which is just a workaround for people still wanting to use Gutenberg Editor, and so not solving anything.

    I saw this post and after some checks, I found out that my .htaccess file got corrupted and was causing this problem.

    I deleted it and regenerated the file going to Settings/Permalinks/Save Changes, which will regenerate the .htaccess file.

    This is how you can solve the problem!

    More info about it here: https://wpcompendium.org/wordpress-management/wordpress-troubleshooting/how-to-fix-a-corrupt-htaccess-file/

    Reply

Leave a Comment