WordPress relies on an internal API called the REST API, served under /wp-json/. The block editor saves posts through it, and WooCommerce and many plugins depend on it. That’s why the failure shows up in several places: under Tools › Site Health, or when you click Update in the editor.
What the error means
The admin sends a request to a path such as /wp-json/wp/v2/posts/123 and expects JSON back. If the request returns an error code (403, 404 or 500), or a response containing HTML or a PHP warning, you see one of these:
The REST API encountered an errororThe REST API encountered an unexpected resultin Site Health.Updating failed. The response is not a valid JSON response.orPublishing failed.in the editor.
Common causes
- Missing or broken rewrite rules in .htaccess, so
/wp-json/returns a 404. - A security plugin disabling or blocking the REST API.
- A web application firewall rule rejecting the request with a 403, especially when the post contains code or text that looks like a query.
- PHP warnings printed on screen, landing before the JSON and corrupting it.
- Mismatched site addresses in settings (http vs https, www vs non-www).
- The domain pointing at another server, or a password-protected folder, so the site’s request to itself (loopback) fails.
How to fix it
- Open the API directly: visit
https://example.com/wp-json/. You should see text starting with{"name":. A 404 means a rewrite problem; a 403 means something is blocking it. - Try the fallback route: open
https://example.com/?rest_route=/. If this works while/wp-json/doesn’t, permalinks are the cause. - Re-save permalinks: under Settings › Permalinks, click Save Changes without changing anything, and WordPress rewrites its rules. If
.htaccessis damaged, restore the default block in Files › File Manager:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
- Read the real response: in the editor, open developer tools (F12) › Network, click Update, and open the failed
wp-jsonrequest. You’ll see the status code and the response body, which may be a PHP warning naming the plugin. - Hide warnings from output with
define( 'WP_DEBUG_DISPLAY', false );inwp-config.php, as described in Cannot modify header information. - Match the site URLs: under Settings › General, WordPress Address and Site Address must match and both start with
https://. - Test plugins: temporarily disable security and caching plugins, or use the Troubleshooting mode of the Health Check plugin, which disables plugins for your session only while visitors see the normal site.
- If the 403 comes from the firewall, see ModSecurity 403 and send support the time and URL.
- If the loopback request fails, make sure the domain points to your current server; see domain not pointing to hosting.
Prevention
- Don’t disable the REST API entirely; restrict only sensitive routes.
- Keep
display_errorsoff on the live site. - After a migration or domain change, re-save permalinks and open Site Health.
On ArabyHost
The LiteSpeed web server reads .htaccess, so WordPress’s default rewrite rules work as they are. Imunify360 protects sites from malicious requests; if a legitimate editor request gets blocked, send support the time and URL so they can check the rule. The Araby AI assistant reads the error log and explains why the request failed. More on our WordPress hosting.
FAQ
Why can't I save posts because of the REST API?
The block editor (Gutenberg) saves everything through the REST API. If that request fails or returns something other than JSON, you get "Updating failed. The response is not a valid JSON response." and the change isn't saved.
Does disabling the REST API make the site safer?
Turning it off completely breaks the editor and many plugins, WooCommerce included. Restrict specific routes for logged-out visitors, such as the users list, instead of switching the whole API off.
What does "Your site could not complete a loopback request" mean?
Your site couldn't connect to itself, which WordPress needs for scheduled tasks and error checks. Usually the domain points to another server, or a firewall or folder password blocks the request.