Fix the WordPress JSON Error


While setting up the WordPress blog I ran into an, apparently, fairly common beginner’s error. Whenever I tried creating and saving or updating a post, I got a “not a valid JSON response” error. I searched online and found various sources suggesting the following:

  • Changing the permlinks setting (which will regenerate the .htaccess file)
  • Using the Classic editor
  • Installing a Simple SSL plugin
  • Disable all plugins
  • Running a site health check and fixing the problems it finds
  • Make sure the URLs for the website in the Settings>General panel match

However, none of these suggestions worked for me. I finally figured out that when I disabled the ModeSecurity module in my cPanel on my Namecheap hosting site everything worked like a charm. This made me realize that it was probably a ModSecurity firewall rule that was incorrectly blocking WordPress requests. My suspicion was confirmed by this message on the cPanel:

Of course, ModSecurity is very useful to avert threats to the website, so I didn’t want to keep it permanently turned off. Neither did I turn it off and on every time between creating posts. So I contacted my hosting company, Namecheap, and their wonderful support staff fixed the rules within minutes.

A few days earlier they had also helped me with an SSL certificate issue. I continue to be impressed with Namecheap as a reliable hosting provider.

Build your website!