If you’re trying to publish a post in WordPress and see:
“Publishing failed. The response is not a valid JSON response.”
this means something is blocking WordPress REST API. Here are the quickest ways to fix it.


1. Refresh Your Permalinks

This solves the issue most of the time.

  1. Go to Settings → Permalinks
  2. Click Save Changes (don’t edit anything)

WordPress rebuilds .htaccess and fixes the broken routes.


2. Fix Wrong Site URLs

If your Site URL and WordPress URL don’t match, WordPress returns invalid JSON.

Go to:
Settings → General

Make sure both are identical:

https://yourdomain.com

No “www.” mismatch, no http/https mismatch.


3. Disable Security Plugins Blocking REST API

Security plugins often block REST requests.

Temporarily disable:

  • WordFence
  • WP Cerber
  • iThemes Security
  • Hide My WP
  • Limit Login Attempts

Try publishing again. If it works, reactivate plugins one by one to find the culprit.


4. Cloudflare Block or Rocket Loader Issue

If your site uses Cloudflare, two things can break JSON response.

A. Firewall Blocking REST API

Go to: Cloudflare → Security → Events
If REST URLs are blocked → allow them.

B. Disable Rocket Loader

Go to: Speed → Optimization
Turn Rocket Loader → OFF


5. Fix Mixed Content (HTTP/HTTPS Conflict)

If some assets load over HTTP and some over HTTPS, JSON breaks.

Quick Fix

Install Really Simple SSL and let it fix everything automatically.


6. Plugin or Theme Conflict

Something might be breaking REST routes.

Steps:

  1. Disable all plugins
  2. Try publishing
  3. If it works → reactivate plugins one by one
  4. If not → switch to a default theme (Twenty Twenty-Four) and test

7. Hosting ModSecurity Blocking Editor

Some hosting providers have strict ModSecurity rules.

Ask your hosting support:
“Please whitelist ModSecurity rules blocking WordPress REST API for my domain.”

Or turn off ModSecurity from cPanel if allowed.


8. Incorrect .htaccess File

A corrupted or altered .htaccess can cause this.

Default WordPress .htaccess:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

Replace your existing one if needed.