Updating failed in the WordPress editor: the REST API and JSON errors

The short answer: you write a post, press Update, and the editor answers “Updating failed. The response is not a valid JSON response” (or “Publishing failed”). The editor talks to the site through a door called the REST API; this message means the reply did not come back as it should. The causes are few, and there is an order to test them.

The causes, in order

Cause How to recognise it
1. Broken permalinks or .htaccess The address your-domain.com/wp-json/ gives 404. This is the most common cause.
2. Site address different from the one you use The site opens on https, but the settings say http (or with and without www).
3. A protection blocking the request A security plugin, ModSecurity or Cloudflare refuses the request; it gives 403.
4. A plugin writing warnings PHP writes text before the JSON, which stops being valid.
5. Cache or CDN A rule that stores or changes the dashboard’s requests.

Testing, step by step

1 Open the address your-domain.com/wp-json/ in the browser. You should see a lot of text between braces. If you see a 404 or a page of the site, go to step 2; if you see 403, step 4.
2 Save the permalinks again: Settings > Permalinks, changing nothing, “Save Changes”. Permalinks and the 404.
3 Check the addresses under Settings > General: both should be the same and start with https, if the site has a certificate: Changing the WordPress site address.
4 If the request is blocked, look at ModSecurity, the security plugin and Cloudflare: ModSecurity.
5 Deactivate plugins one by one and repeat: Disabling plugins. Switch on the error log to see the warning: Debug mode.
Before you touch anything, copy the text you wrote somewhere safe: in some failures the editor does not save the post. And do not switch the REST API off “to fix it”: the block editor stops working.
The same message appears when the session has ended and the dashboard is still open. Before anything, open the dashboard in another tab, log in again and try once more.

Followed the whole order and the error remains? Open a ticket with the address and what you see at /wp-json/.

Open a support ticket

SEE ALSO

WordPress permalinks and the 404 that follows

ModSecurity and web application firewalls: what they do, and what to do when one blocks you

Disabling plugins, including when you cannot get in

Common WordPress errors: white screen, critical error and how to find the cause

RECOMMENDED PRODUCT

WordPress hosting

One-click install, updates handled, and speed that holds up. from $6.59/mo (3-year plan, with coupon)

See plans
  • 0 Users Found This Useful
Was this answer helpful?

Powered by WHMCompleteSolution