Have you ever seen the below warning when trying to update your WordPress Version or a WordPress Plugin?
This error will occur when file permissions and ownerships are not set correctly on your site’s server. This will then show the annoying popup that will force you to enter your FTP credentials each time you’d like to make a change to your site and its plugins.
A super quick solution to the problem is adding the following to your
define( 'FS_METHOD', 'direct' );
This function allows the current user to edit or install files in your folder. Although this is a quick solution to the problem, we still advise on using Method 2 if you have SSH access to your server.
The way to fix the error is to make sure our projects files and directories permissions are all set correctly.
In order to do this, we need to start by changing the ownership of your project (along with all the contents inside) so that it’s owned by the correct user on your web server. As an example, NGINX typically runs under the user www-data, while Apache typically runs under the user apache.
To change your project’s ownership, we need to connect to the server using SSH and then run one of the following commands:
sudo chown www-data:www-data my-project -R
sudo chown apache:apache my-project -R
This alone may fix your issue, but if that is not the case, you’ll also need to ensure that your project has file permissions of 755, meaning that NGINX or Apache has the ability to write files to your server. You can ensure this is correct by using the following command:
NGINX and Apache Servers:
sudo chmod 755 my-project -R
Once your project’s ownership and permissions are set correctly the error should disappear which will allow you to install and update plugins as normal again.
What if I am running my site on a Shared Hosting Provider, e.g. GoDaddy, Bluehost, SiteGround?
If this is the case, then it’s unlikely that you’ll have the permissions to change the ownership of your directories. That being said, the issue most likely related to your project’s permissions, rather than the ownership.
Have a look through your hosting provider’s interface (e.g. cPanel/Plesk) to change the file permissions. If you manage to find the option then you can change your project and it’s content’s permissions to 755 and it should resolve the issue. If you are using an FTP client like FileZilla, then you can change them in here. Just make sure to set the value to 755 and recurse into the subdirectories; but only to directories only. Directories should always have 755 permission, whereas files should only have 644.
If that still doesn’t fix the issue, then we would recommend getting in touch with your hosting provider’s support team, they’re almost always able to help in such situations and typically get the job done rather quickly.
We hope that helps you overcome the error, if you need any help with this, feel free to get in touch or drop us a comment below!