Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

WordPress cannot create the folder for a plugin, theme or update

ErrorCould not create directory.

Short answer

WordPress tries to create a folder under wp-content for the new plugin or theme and the operating system refuses. The web server account cannot write there, or WordPress picked a transfer method that does not fit your host. Check who owns wp-content and its upgrade and plugins folders, then fix ownership or set the filesystem method.

  • Applies to WordPress 6.8, PHP 8.3, Ubuntu 24.04
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Find out which user owns the WordPress files and which user the web server runs as. Compare the owner of wp-content with the account PHP runs under.

    ls -ld wp-content wp-content/plugins wp-content/upgrade
    ls -l wp-config.php
  2. 2Match what you see, then jump to its fix

    1. 1Could not create directory. on every install or update, and wp-content is owned by another user (often root or an SFTP user).The web server account cannot write to wp-contentFix
    2. 2A connection-information form asks for FTP credentials, or Could not access filesystem. appears.WordPress cannot use direct file access, so it falls back to FTPFix
    3. 3The FTP form is used, but the install still fails with Could not create directory. or Filesystem error.FTP settings that do not match the serverFix

What does the error look like?

  • Could not create directory.
  • Could not access filesystem.
  • Filesystem error.

Cause 1 of 3

The web server account cannot write to wp-content

1Check

WordPress documents wp-content as the folder intended to be writable by both your user account and the web server process. Look at the owner and mode shown by ls -ld above.

sudo -u www-data test -w wp-content/plugins && echo writable || echo not-writable

2Fix

Make the files WordPress must write group-owned by the web server account, and keep directories 755 and files 644 for everything else, as the hardening guide describes. www-data here is an example; use your server's account.

sudo chgrp -R www-data wp-content
sudo find wp-content -type d -exec chmod g+w {} \;

3Verify

Try the plugin install again from Plugins, Add New.

ls -ld wp-content wp-content/plugins

Confirmed by developer.wordpress.org

Did this fix it?

Cause 2 of 3

WordPress cannot use direct file access, so it falls back to FTP

1Check

WordPress writes directly only when the files it creates have the same owner as the WordPress files; otherwise it falls back to ssh2, FTP extension or FTP sockets and shows the form unless credentials are stored.

grep -n "FS_METHOD\|FTP_" wp-config.php

2Fix

If you cannot change ownership, tell WordPress to write directly with FS_METHOD in wp-config.php. The docs say to change it only for update problems, and to remove it if it does not help. Or set the FTP constants for a real FTP or SSH account.

// wp-config.php, above the line 'That's all, stop editing!'
define( 'FS_METHOD', 'direct' );

3Verify

Reload the admin page: the connection form disappears and the install runs.

grep -n "FS_METHOD" wp-config.php

Confirmed by developer.wordpress.org

Did this fix it?

Cause 3 of 3

FTP settings that do not match the server

1Check

FTP_BASE and FTP_CONTENT_DIR must be the full paths of the WordPress base and wp-content folders as the FTP account sees them; FTP_HOST is host:port. The docs also note some hosts need FTP_HOST set to localhost.

grep -n "FTP_" wp-config.php

2Fix

Correct the paths and host in wp-config.php. If the host uses restrictive permissions on all user files, FS_CHMOD_DIR and FS_CHMOD_FILE override the defaults (octal values with a leading 0, no quotes).

define( 'FTP_HOST', 'localhost' );

3Verify

Run the install again; if it still fails, remove the FTP constants again so you are not testing two things.

grep -n "FTP_" wp-config.php

Confirmed by developer.wordpress.org

Did this fix it?

How do I stop it coming back?

  • Pick one ownership scheme for the site and keep it after every deploy: your account owns, the web server account has group write only on wp-content.
  • Do not open everything to everyone as a fix; the WordPress hardening guide says plugin files should be writable only by your user account.
  • Remove FS_METHOD and the FTP constants again if they did not fix the problem, as the WordPress docs advise.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Back end

CodeIgniter 4 cannot write its cache files

CodeIgniter\Cache\Exceptions\CacheException: Cache unable to write to /var/www/app/writable/cache/

CodeIgniter 4's file cache needs a cache directory that the web server can really write to.

2 causes, each with a fix

Back end

CodeIgniter 3 loads the model but the property is undefined

The model name you are loading is the name of a resource that is already being used: user

CodeIgniter 3 expects a model file named like its class, with the first letter capitalised, for example User_model.php holding class User_model.

2 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.