While working on a new WordPress site, I encountered this error. It seemed weird as everything was just brand new (except that I had to move files around though).
The error occurred when I tried to save the draft while creating a new post or when trying to preview the draft.
In fact the preview window also showed 404 not found, instead of showing the preview of the newly created draft post.
I didn’t check the error while publishing the post, but I suspect that it would be the same thing.
Updating failed. Error message: The response is not a valid JSON response.
The solution was simple.
I needed to go to Settings > Permalinks and save or update them again.
What caused the json not valid error?
The error was caused by the missing .htaccess file in WordPress root directory. There can be many reasons for that and that’s beyond the scope of this article.
Another issue can be if you’re using nginx server. You need to confiture the wordpress settings in nginx.conf file first and restart the nginx server to make it work properly.
How to fix Updating failed. Error message: The response is not a valid JSON response
Note that this error can also occur with publishing or uploading too.
As the issue is mainly caused by permalink error, steps to fix it include:
- go to settings > permalinks and save them again
- if you’re using nginx for server, make sure that wordpress rules are added to nginx, if not then add them
- restart nginx after adding those rules
However if you’re still having the error or have any other issue, you can contact me to discuss.
Make sure that Mod_Rewrite is enabled
If you have a valid .htaccess file and you’re still facing this issue, then make sure that mod_rewrite is enabled on your apache server.
If mod_rewrite is not available or disabled, then your permalinks won’t work even if you have correct rules in .htaccess file. The site links would work fine if they’re set to plain, but won’t work if they are set to anything else like post-name etc.
Add wp_siteurl and wp_home in wp-config.php (thanks to Gini)
If the above mentioned steps don’t help, then you can try adding the home_url and site_url to the wp-config.php file. This can be the cause of error if your site has any configuration issue (or desired configuration) which cause conflicts like ssl (non https requests on a site running on https), etc.
How to add wp_home and wp_siteurl in wp-config.php
To define home url wp_home and wp_siteurl with ssl (https), go to your wordpress root directory, edit the wp-config.php file and add this on top:
define( 'WP_HOME', 'https://example.com' ); define( 'WP_SITEURL', 'https://example.com' );
Remember to replace the domain name example.com with your own domain name and correct path. Also make sure that your site is compatible with ssl / https configuration.