Wordpress | Solve the Could Not Create Directory Problem

After migrating an existing Wordpress installation to a new web server I was confronted with a problem regarding the FTP connection to the server. I hope this post may help you to solve this kind of problem as well.

The “Could not create directory” problem


While you are trying to update WordPress or install/update a plugin you may get a message like “Could not create directory” from Wordpress. That means, that the FTP credentials and the FTP connection is okay and upset but something went wrong while executing even simple commands.
Downloading update from ...
Unpacking the update ...
Could not create directory ...

After checking the access rights using a FTP program or SSH it seems, that the ownership of the wordpress directory was not correct. It was set to the root user, as I uploaded the existing wordpress installation using the root FTP account. To solve the problem I had to set the correct user as directory owner and the correct access rights for files and folders separately. Depending on your host you have multiple options:

Fix the ftp problem using SSH commands



  1. Access your wordpress directory (change the path to point to your custom Wordpress directory).

  2. Set the correct user and group as owner. Typically this is the same user as the web server uses (Apache uses a user and group called www-data).

  3. Set the correct read, write and execute rights to all directories and files inside your wordpress directory.


cd /your-wordpress-directory

sudo chown -R www-data:www-data *

sudo find ./ -type d -exec chmod 755 {} \;
sudo find ./ -type f -exec chmod 644 {} \;

You can use this commands directly (without the sudo command) if you are logged in as root user.

Fix the ftp problem using a FTP account


If you do not have ssh access to your server / webspace you have to use any advanced ftp file program. Most of them allows you to execute the ssh command as simple UI interaction.

  1. Find the wordpress installation folder

  2. Open the folder settings and check the ownership of the folder. If it seems incorrect you have to contact your administrator / hosting provider. Maybe you have the option to repair the ownership.

  3. Check the access rights of the folder and files inside your wordpress installation folder. The rights (user/group/other) for directories should be set to 755 (execute/write/write) and the files to 644 (write/read/read).


 
{{ message }}

{{ 'Comments are closed.' | trans }}