Fix ‘Unable to create directory’ error in WordPress
WordPress is the top choice for bloggers when it comes to blogging. While there are multiple hosting options available, self hosted or sites which are not with WordPress hosting may face issue while dealing with media addition to the post. While uploading media on your WordPress site, you might face issue with “Unable to create directory” error.
This is mainly because of the permission issue on the hosting server where your website is hosted. Below are few suggestions on how to correct this issue & how to make sure it will not re-occur in the future.
Checks for Unable to create directory error
First start with checking permissions on wp-content folder on your hosting server. Please note that wp-content is folder available at the path where you have installed WordPress on your hosing server. If it’s not 755, then please change it to 755. For sites running on unix server, you can do it via Filezilla or WinSCP, else if you are connecting to your server via putty or SSH console for cloud provider like Google Cloud Platform, then use below command (without quotes).
chmod -R 755 wp-content
In case 755 permission does not help, try with 775 permission. Do not use 777 permission as it give full access to everyone which is not recommended.
If you are running on Ubuntu UNIX server, then check the owner of the directory where your wordpress site is installed, for ex. /var/www/html.
On Ubuntu Apache web server runs under user www-data and group www-data. Hence the folder owner should be www-data user. If in your case owner is different then note down the current owner and group, now change the owner and group to www-data.
chown -R www-data:www-data /var/www/html
Note that path /var/www/html is just example path, you need to replace this with your actual site installation path.
With these you should be able to correct the error with permission issue thus resolving “Unable to create directory” issue.