If you have a new WordPress installation and you suddenly get the following error:
Updating failed. The response is not a valid JSON response.
This error is usually related to incorrect file ownership and permissions. To fix this, you will need to ask your hosting company to reset file permissions, but if you’re comfortable running a few terminal
commands, then you can read further.
Recommended file permissions
Permissions are described in a coded 3-number format which indicate a combination of Read/Write. These are the recommended file permissions that you can set for your WordPress site:
- Root directory (ie. public_html/): 755
wp-admin
: 755wp-includes
: 755wp-content
: 755wp-content/themes
: 755wp-content/plugins
: 755wp-content/uploads
: 755.htaccess
: 644index.php
: 644wp-config.php
: 640
WordPress directory and folder permissions should be set to 755, and most file permissions need to be set to 644.
Set file and folder permissions using the terminal
The web server daemon has to be run under a specific user. On NIX-based systems, the default is usually the www-data
user. The web server can access any file that www-data
can access. It has no other importance.
Use the following commands to give the www-data
user and www-data
group access to your WordPress installation (please replace /var/www/html/yourdomain.com
with the correct path to your website):
sudo chown -R www-data:www-data /var/www/html/yourdomain.com
Set the permissions for all directories to 775
sudo find /var/www/html/yourdomain.com/ -type d -exec chmod 775 {} \;
Set permissions for all files to 664
sudo find /var/www/html/yourdomain.com/ -type f -exec chmod 664 {} \;
Create an empty .htaccess
file in the root of your website direct using the touch command:
touch /var/www/html/yourdomain.com/.htaccess
Change ownership of .htaccess
to 666:
chmod -v 666 /var/www/html/yourdomain.com/.htaccess
Then head into the WordPress Admin > Settings > Permalinks and click Save Changes
. These settings are then saved to the .htaccess
file.
That’s it, you’re done!