Trying to upgrade a WordPress plugin or theme or a new version of WordPress? Finally, got into an error saying “could not create directory”. You are not alone, almost any of the WordPress users had faced it. In fact, I also faced this kind of error in the past.
The error looks something like this below:
Unpacking the package…
Installing the theme…
Could not create directory. /home/yourblog/public_html/wp-content/themes/yourtheme/
Theme install failed.
Downloading update from https://downloads.wordpress.org/plugin/yourplugin/…
Unpacking the update…
Could not create directory.
First, Why do you get “Could not create directory” error?
Let’s see the reason for this issue and understand why this error is coming on your WordPress blog.
As the error clearly states, WordPress is not able to create a directory. If you don’t know all of the WordPress core files and folders are available from the root directory of your blog.
If you are not familiar, all your WordPress plugins are stored in the directory /wp-content/plugins/. Similarly, all your WordPress theme files are stored in the directory /wp-content/themes/.
Whenever you install a new plugin, it creates a directory inside the /wp-content/plugins/ folder. Similarly, when there is an update in the plugin/theme, WordPress re-creates the folder.
Since WordPress is not able to create a directory during an upgrade, it is throwing an error “could not create directory”.
The root cause of this issue is the access permissions.
Method #1: Update the Folder permissions from the web hosting cPanel.
In your web hosting server, every folder will have permissions like read/write/execute. Based on the user either admin or a normal user, the permission of these folder/files shall be customized.
The easiest way to fix the “could not create a directory” error is to check the folder permission and make sure it has writable permission (set as 755). You can also change the permission to Writable from the File Manager available on the web hosting cPanel’s.
Let’s see how to check the directory permission and fix it.
- Login to your web hosting account.
- Go to the cPanel’s page.
- Open the “File Manager”.
- Go to the root folder and you will be seeing the folder /wp-content/.
- Select it and set permission as 755.
- Or check the Write option as shown below and Save it.
- Similarly, you change the permission for /wp-content/plugins/ (for plugin error), /wp-content/themes/ (for theme error).
You can now login to WordPress dashboard and try to upgrade the plugin again – this time it will happen without throwing any errors.
Setting 755 means:
- Read, Write, Execute permission for the Owner (that’s you or your login)
- Read, Execute permission to Group (generally, Linux has the concept of grouping multiple users a group, we are revoking write permission to others for higher security)
- Read, Execute permission to the rest of people (say your blog visitors)
As an extra step, you can make sure all the WordPress folders are setup with 755 permission. You can refer to the list of all WordPress folders from here (important root folders are wp-content, wp-includes, wp-admin, upgrade).
Method #2: Update FTP Permissions in wp-config.php file.
In case, if you are still facing the issue even after changing the folder permission then try this method to update the FTP credentials.
This is something like the server is trying to perform the upgrade operation for you and it doesn’t get the credentials to perform a write operation, it fails. Hence you have to add the credential details to your wp-config.php file.
- All you have to open the File Manager from your web hosting account and open the file wp-config.php locating at the root folder of your WordPress blog.
- Add the below lines (make sure you replace with your own information):
Don’t forget to save the wp-config.php file.
- If you are not familiar or not comfortable to edit the wp-config.php file then you can use the FTP Access plugin to do the same. Once you install this plugin, just enter the FTP login’s username, password and Save it.
Now go back to your WordPress blog’s dashboard and try to perform the upgrade again. This time, you will see that the plugin/theme update goes through without any issues.
Personally, I researched about this directory creation error and found that the above-mentioned methods are working for many WordPress users.
In case, if you are able to fix this issue using a different method, please leave a comment below. It may help other WordPress users also.