About this article: This article is reviewed against the cited sources. This is source research, not lab validation. Check the stated versions and your own requirements before making changes.
The block editor saves a post by sending a request to the site's REST API and expects JSON back. "Updating failed. The response is not a valid JSON response." means the answer was something else: an HTML error page, an empty reply, or text such as a PHP warning in front of the JSON. Reading that answer in the browser's Network panel names the layer to fix. The wording is "Publishing failed." or "Scheduling failed." when the post was being published or scheduled.
What the error means
Two small pieces of the editor produce the message, and both ship in the WordPress 6.7.1 release. In wp-includes/js/dist/api-fetch.js, the code defines an error with the code invalid_json and the message "The response is not a valid JSON response." It is thrown when the response has no json function or when reading the JSON fails. The same file throws any response outside the 200 to 299 range as an error, and the code then tries to read its body as JSON as well. Our own reading: an error page that is HTML therefore ends in this same message, whatever its status.
In wp-includes/js/dist/editor.js, the save-failure notice starts with "Updating failed." and, if the error has a message without HTML in it, joins that message on with a space. That is how the two sentences end up together.
The REST API handbook says the API lives at /wp-json/ when pretty permalinks are enabled, and that otherwise the route goes in the query string as rest_route, for example http://oursite.com/?rest_route=/.
Likely causes
| Cause | What you see in the Network panel | How to confirm |
|---|---|---|
| A plugin or theme prints text (a warning, a notice or stray output) before the JSON | Status 200, Response starts with text, then the JSON | The text names a file path under wp-content/plugins or themes |
| The server, a firewall or a security plugin answers with its own page | A status such as 403 or 5xx and an HTML Response | The page names the server or the security product |
The REST route is not reachable (permalinks or try_files) |
Status 404 and an HTML page for the wp-json address |
/wp-json/ in the browser does not show JSON |
| The request is redirected to another address | A redirect status, then an HTML page | The Headers tab shows a Location line |
| A PHP failure ends the request with no JSON | An empty Response, or an error page | The PHP error log has a fatal error at that time |
| The saved content is too large for a limit on the way | An error page from the web server | A 413 status |
Prove the cause before changing anything
All of these steps only read.
1. Record the failing request. Open the browser's developer tools and the Network panel, and tick Preserve log. Google's reference says that by default DevTools records requests while it is open and that Preserve log keeps them across page loads. Repeat the save.
2. Find the request. Look in the Name column for the one whose address contains wp-json or rest_route, at the time of the failed save.
3. Read its status. Select it, open the Headers tab and look in the General section. DevTools shows the status code with a readable message beside it.
4. Read its answer. Select the same request and open the Response tab. A good answer is JSON from the first character. A bad answer is HTML, a plain text message, an empty body, or text before the first curly bracket.
5. Test the REST index. With a pretty permalink site, open https://www.example.com/wp-json/ in a browser. The handbook says it returns a JSON index of the available routes. To see the status line and headers together with the body, run the command below. The curl manual describes -i as showing the response headers in the same output as the data.
curl -i https://www.example.com/wp-json/
A good result is a 200 status and a body that starts with a curly bracket. A 404 and an HTML body match the handbook's advice to enable pretty permalinks or use rest_route. Try https://www.example.com/?rest_route=/ as well.
6. Read the PHP error log. If step 4 shows a warning, the file path in it names the plugin or theme. If the response is empty, look for a fatal error at the same time.
Fix
A plugin or theme prints text before the JSON
WordPress documents WP_DEBUG_DISPLAY as the control that decides whether debug messages are "shown inside the HTML of pages". Our own reading: a message printed that way during a REST request lands in the answer ahead of the JSON. The lasting fix is to repair or replace the code that produces the message. To prove the culprit, deactivate the plugin named in the path, one plugin at a time.
First save the current state: write down the name and version of the plugin and whether it is active, and the time.
Risk: the next step switches the plugin off for every visitor at once. Anything it provides on the front of the site stops until you turn it on again, and a plugin that guards forms or payments leaves them unguarded.
On the Plugins screen, click Deactivate under that plugin, then save the post again.
To undo it: click Activate for the plugin you wrote down, and check that its version is the one you recorded.
The REST route is not reachable
If /wp-json/ gives 404 on a site with pretty permalinks, the handbook's advice is to enable pretty permalinks or use rest_route. The permalinks documentation says that "Visiting the Permalinks screen triggers a flush of rewrite rules" and that there is no need to save just to flush them.
First save the current state: write down the current permalink structure and the time.
Risk: the next step makes WordPress flush the site's rewrite rules, which the permalinks page says a visit to that screen does. Do not change or save the structure unless you mean to: our own reading of the page is that saving also writes the .htaccess file when it is writable, and a different structure changes every address on the site.
Open the Settings Permalinks screen and do not change anything. Then request /wp-json/ again.
To undo it: if the structure on the screen differs from the value you wrote down, set it back to that value and save, then request /wp-json/ again.
An nginx site loses the query string
The REST API handbook says that if query parameters have no effect on an nginx site, a try_files line ending in /index.php$args should end in /index.php$is_args$args, because the nginx variable $is_args is a question mark when a request line has arguments and empty otherwise. Our own reading: a site on rest_route addresses depends on that query string reaching PHP.
First save the current state. POSIX cp with -p duplicates "The time of last data modification and time of last access" of the source file in the copy.
cp -p /etc/nginx/conf.d/example.com.conf /etc/nginx/conf.d/example.com.conf.2026-12-04
Risk: the next edit changes how nginx passes every request for this site to PHP, and a mistake can take the site down at the next reload.
In that file, change the line to:
try_files $uri $uri/ /index.php$is_args$args;
Only if you need to back out before the reload: copy the saved file back over the original. This discards the edit and any other change made since the copy.
Risk: the next command overwrites the site's nginx configuration file with the copy saved before the edit.
cp -p /etc/nginx/conf.d/example.com.conf.2026-12-04 /etc/nginx/conf.d/example.com.conf
Check the configuration before it is applied. nginx documents -t as testing the configuration file.
nginx -t
The nginx page says the test checks the syntax and then tries to open the files the configuration refers to. If it prints an error, do not go on; put the saved file back first.
Disruptive step: the next command makes nginx start new worker processes with the edited configuration and shut down the old ones gracefully.
nginx -s reload
To undo it after the reload: first copy the saved file back over the original. This discards the edit and any other change made since the copy.
Risk: the next command overwrites the site's nginx configuration file with the copy saved before the edit.
cp -p /etc/nginx/conf.d/example.com.conf.2026-12-04 /etc/nginx/conf.d/example.com.conf
Then check the configuration again.
nginx -t
Disruptive step: the next command makes nginx start new worker processes with the restored configuration and shut down the old ones gracefully.
nginx -s reload
Then request /wp-json/ again to see the state you went back to.
A server rule, firewall, redirect or size limit
When step 3 and step 4 show an error page from the web server or a security layer, our own advice is that the change belongs in that layer's own settings or log, and the error page often names the product. A redirect to another address, such as http to https or a different host name, is read from the Location line in the Headers tab. For a 413 reply, see nginx 413 Request Entity Too Large: client_max_body_size and the limits behind it.
Example (illustrative): on web01, an editor of www.example.com gets "Updating failed. The response is not a valid JSON response." on every save. The Network panel shows a wp-json request with status 200, and the Response tab starts with Warning: Undefined variable and a path under wp-content/plugins/example-forms/, followed by the JSON. The administrator writes down the plugin's name and version, deactivates it, and the next save works. The plugin's developer is told which line printed the warning.
Confirm the fix
- Repeat the save with the Network panel open. The request should return its status with JSON from the first character.
- Reload the editor and check that your change was saved.
- Open
https://www.example.com/wp-json/and confirm it shows JSON.
What to watch afterwards
- Our own advice: keep error display off on a live site and send errors to a log, as the debugging page describes with
WP_DEBUG_LOG, so that warnings cannot land in a response. - After a plugin, theme or PHP update, save one post as a check.
- A save that fails only for large posts points at a size limit in front of PHP.
Read next
Related articles you may want next.
- HostingWordPress Site Health "The REST API encountered an error": read the code, then find what blocks the requestSite Health says The REST API encountered an error. Read the response line, test /wp-json/ from the server, then fix the network, rule or rewrite cause.Read article
- TroubleshootingWordPress "There has been a critical error on this website": read the PHP error, then fix the causeWordPress 'There has been a critical error on this website': read the admin email and error log, use recovery mode, then fix the plugin, theme or PHP.Read article
- HostingWordPress login "Cookies are blocked or not supported by your browser": the test cookie, COOKIE_DOMAIN and the Secure flagWordPress 'Cookies are blocked or not supported by your browser.' means the login test cookie did not return. Check the browser, COOKIE_DOMAIN, HTTPS.Read article
Risks and limits
- These commands have not been run or lab-tested.
- The message is the editor's, not the server's. The same words can come from different layers, so the Response tab is the thing to follow.
- The file paths in the commands are examples.
- Deactivating a plugin and reloading nginx affect every visitor while they happen.
- The editor files were read in the WordPress 6.7.1 release; other WordPress versions can differ.
Sources
- REST API Handbook: Key Concepts — WordPress Developer Resources, page dated 14 October 2026, accessed 4 December 2026
- Frequently Asked Questions — WordPress Developer Resources (REST API Handbook), page dated 14 October 2026, accessed 4 December 2026
- Debugging in WordPress — WordPress Developer Resources, page dated 14 October 2026, accessed 4 December 2026
- Settings Permalinks screen — WordPress.org Documentation, page dated 8 June 2024, accessed 4 December 2026
- Manage Plugins — WordPress.org Documentation, page dated 10 January 2026, accessed 4 December 2026
- Network features reference — Chrome for Developers, page dated 16 July 2024, accessed 4 December 2026
- curl man page — curl project, no date shown, accessed 4 December 2026
- Command-line parameters — nginx documentation, no date shown, accessed 4 December 2026
- cp — The Open Group Base Specifications Issue 7, 2018 edition, no date shown, accessed 4 December 2026
- Module ngx_http_core_module — nginx documentation, no date shown, accessed 4 December 2026
- wp-includes/js/dist/api-fetch.js at tags/6.7.1 — WordPress release file at a fixed tag, no date shown, accessed 4 December 2026
- wp-includes/js/dist/editor.js at tags/6.7.1 — WordPress release file at a fixed tag, no date shown, accessed 4 December 2026
This article was originally published on .