Installation Failed: Could Not Create Directory in WordPress
You try to install or update a plugin or theme and WordPress stops with “Installation failed: Could not create directory.” Related messages include “Destination folder already exists”, “Could not copy files. You may have run out of disk space” and a request for FTP details you never needed before. They all mean WordPress could not write to the folders where plugins and themes live. This guide explains each message, how to check permissions, ownership and disk space, and how to fix it without making the site less secure.
Checked: 14 November 2026. Re-verified against WordPress 7.1.4, the current stable release.
How this was checked: the permission numbers were read in the official WordPress documentation (“Changing File Permissions”); the ownership test was read in get_filesystem_method() and the failure path in copy_dir() in the WordPress source references on developer.wordpress.org; the disk-space check was read in _unzip_file_ziparchive() and _unzip_file_pclzip(). No test site was used and the error was not reproduced — anything this guide did not verify is marked as such where it appears.
TL;DR — the short version
- Check disk space first. If the account is full, nothing else matters. Look at disk and inode (file-count) usage in your hosting panel.
- Then check ownership, not just permissions. Folders at
755and files at644only work when the files belong to the account PHP runs as. A folder can show755and still refuse WordPress if someone else owns it. - Never set anything to
777. It does not fix an ownership problem, and it lets any process on the server write to your site. - If WordPress asks for FTP details, that is a clue, not a separate problem. It means the ownership test failed. Fix ownership; do not just add
define( 'FS_METHOD', 'direct' );to hide the prompt. - If it worked yesterday and broke today, something changed ownership or filled the disk: a migration, a restore, a plugin installed over SSH as root, or backups piling up inside the account. Start there.
What each message means
These messages come from WordPress’s upgrader, the code that downloads, unzips and moves plugin and theme files.
| Message | What failed |
|---|---|
| Could not create directory. | WordPress could not make a new folder, usually in wp-content/upgrade or wp-content/plugins |
| Destination folder already exists. | A folder with the plugin’s name is already in wp-content/plugins |
| Could not copy files. You may have run out of disk space. | Unzipping or copying stopped, often because the account is full |
| The update cannot be installed because some files could not be copied. This is usually due to inconsistent file permissions. | During a WordPress core update, some existing core files cannot be overwritten |
| “To perform the requested action, WordPress needs to access your web server” (asks for FTP details) | WordPress decided it cannot write files directly |
The last message is a clue. WordPress tests whether it can write directly by creating a temporary file in wp-content and comparing its owner with the owner of WordPress’s own files. The get_filesystem_method() reference describes this: if the owners match, WordPress writes files directly; if they do not, it falls back to FTP or SSH and asks for credentials.
Diagnose it first: symptom → likely cause → where to look
| What you see | Most likely cause | Where to look |
|---|---|---|
| “Could not create directory.” on a plugin or theme install | PHP cannot create a folder inside wp-content – usually ownership, not the 755/644 numbers. The failing folder can be deep inside a plugin, not only at the top level. | Owner and writability of wp-content/plugins (or themes) and its subfolders. See “Why permissions can look right and still fail” below. |
| “Destination folder already exists.” | A leftover folder from a failed or half-deleted install. | wp-content/plugins or wp-content/themes – rename the leftover folder and try again, or use “Replace current with uploaded” (Step 4). |
| “Could not copy files. You may have run out of disk space.” | Disk full, inode limit reached, or account quota hit. Note: WordPress only checks free space before an automatic (cron) update – a manual update gets no early warning and fails later. | Hosting panel disk + inode usage; df -h over SSH if you have it. See “The disk-space check that only runs on cron” below. |
| “To perform the requested action, WordPress needs to access your web server” (asks for FTP details) | The ownership test failed: your files belong to a different account than the one PHP runs as. | File ownership of the WordPress folder. Fix ownership; do not just force FS_METHOD to direct. |
| “The update cannot be installed because some files could not be copied.” (core update) | Existing core files in wp-admin or wp-includes are not writable by PHP. | Ownership and permissions of the WordPress root, wp-admin and wp-includes. |
| Install fails, then the site shows “Briefly unavailable for scheduled maintenance” | The update stopped part-way and left the .maintenance file behind. | See our guide: Briefly unavailable for scheduled maintenance |
Work down the table in order. Most cases stop at the first two rows.
Step 1: Check disk space
Open your hosting control panel and look at disk usage and inode (file count) usage. If either is at or near the limit, WordPress cannot create new files.
- Delete old backups stored inside the hosting account, especially full-site backup archives.
- Remove unused plugins and themes from the dashboard.
- Check
wp-content/upgradeandwp-content/upgrade-temp-backupfor leftovers from failed updates; files there that are days old can be removed. One caution:upgrade-temp-backupholds the previous copy of a plugin or theme while an update runs, so WordPress can roll back if the update fails — do not delete a fresh folder there right after a failed update. Delete it only once the live plugin or theme is confirmed working.
The disk-space check that only runs on cron
WordPress does check free space before unzipping an update — but only during automatic background updates. In _unzip_file_ziparchive() (and the fallback _unzip_file_pclzip()), it works out the space it needs as the uncompressed size of the package multiplied by 2.1 — enough room to unzip the files and copy them into place, with a 10% buffer — and compares that with the free space in wp-content. The catch is the guard around the check: it only runs if ( wp_doing_cron() ).
What that means in practice:
- An automatic update that would not fit stops early with “Could not copy files. You may have run out of disk space.” That is the check working.
- A manual update you start from the dashboard gets no early warning. It downloads, unzips, and then fails at the write — with a less helpful message, and sometimes part-way through.
As an example only: a plugin that expands to 50 MB needs about 105 MB free (50 × 2.1). Your own number depends on the size of the package you are installing, so check your real free space rather than memorising a number:
df -h /var/www/example/wp-content
If you have SSH access, that one command tells you the truth faster than the hosting panel. If disk space is fine but the message persists, check inode usage too — a full file count stops new files just like a full disk — and remember that a failed core update treats a full disk as critical and tries to roll back, so check the site still loads after clearing space.
If your automatic updates never seem to run at all, the cron side may be the problem rather than the disk: see WordPress missed schedule / WP-Cron.
Step 2: Check folder permissions
The WordPress file permissions documentation recommends, for shared hosting where PHP runs as your own account, that “All directories should be 755 or 750. All files should be 644 or 640”, with wp-config.php at 440 or 400. It also says no directory “should ever be given 777, even upload directories”.
In your host’s file manager or an SFTP client, check:
wp-contentand itsplugins,themes,uploadsandupgradefolders:755- Files inside them:
644
If a folder shows something stricter, such as 555, set it back to 755 and try again.
Setting folders to 777 can make an install work, but it lets any process on the server write to your site. Change it back and fix ownership instead.
Step 3: Check file ownership
Permissions only help when the files belong to the account PHP runs as. After a migration, a restore or files uploaded by another user, they may belong to someone else.
- On shared or managed hosting you usually cannot change ownership yourself. Many hosts have a “fix permissions” or “reset ownership” tool in the control panel; otherwise ask support to reset ownership of the WordPress folder to your account.
- On your own server, the owner should be the user PHP-FPM runs as. Changing it needs root access and
chown. If you manage your own server, check which user your PHP pool runs as before changing anything.
Once ownership matches, WordPress stops asking for FTP details and installs work normally.
Some guides suggest adding define( 'FS_METHOD', 'direct' ); to wp-config.php. This skips WordPress’s ownership test entirely — the constant is read before the test runs, so the FTP prompt disappears. But it does not give PHP permission to write anything, and it does not change who owns any file. If a folder is owned by root, the mkdir fails exactly as before, and now you have hidden the one clue that told you why. The official WordPress documentation says to change FS_METHOD only if you have update problems, and to change it back or remove it if it does not help — and that forcing direct “is fraught with opening up security issues on poorly configured hosts”. Use it only when the ownership check gives a wrong answer on a setup where writing already works, such as some container or shared-storage layouts. Fix ownership first.
Why permissions can look right and still fail
Permissions and ownership are two different things, and this error is usually about the second one.
- Permissions are the numbers:
755on folders,644on files. They say what the owner, the group and everyone else may do. - Ownership is who owns the file. If PHP runs as one account and the files belong to another,
755still means “not writable by PHP”.
That is why the FTP-details prompt and this error are the same problem in two clothes. WordPress tests ownership by creating a temporary file in wp-content and comparing its owner with the owner of its own file, wp-admin/includes/file.php. If they match, it writes directly. If they do not, it asks for FTP details — or, if it gets past that test, it can still fail later when it reaches a deeper folder owned by someone else. The test checks one directory, not every folder inside it.
The common way this happens: WP-CLI run as root
If you (or a script) run WP-CLI as root — for example wp plugin install some-plugin --allow-root — the files it creates belong to root. The dashboard, running as the PHP user, then cannot write inside those folders, and the next update of that plugin fails with “Could not create directory.” The same happens with files unzipped or copied over SSH as root, and with restores and migrations done as the wrong user.
Find the folder PHP cannot write (read-only check)
Run this as the user PHP runs as, not as yourself. First find that user:
ps -eo user,comm | grep -i php-fpm | sort -u
Then list every directory under wp-content that user cannot write to. Replace the user and path with your own:
sudo -u www-data find /var/www/example/wp-content -type d ! -writable
Any line printed is a candidate. Check the owner of each one:
ls -ld /var/www/example/wp-content/plugins/some-plugin
If the owner is root, or a different account from the rest of the tree, you have found the cause. On shared or managed hosting, ask your host to reset ownership of the WordPress folder to your account — you usually cannot change it yourself. On your own server, give the tree back to the PHP user (back up first):
sudo chown -R www-data:www-data /var/www/example/wp-content
Use the user and group your server really uses. On a host where each site has its own user, that is the site user, not www-data. And from now on, run WP-CLI as that same user — never as root (see Step 5).
Step 4: Fix “Destination folder already exists”
This happens when a previous install failed half-way or a plugin was deleted incompletely.
- Check whether the plugin is listed under Plugins. If it is and works, you do not need to install it again.
- If you are uploading a ZIP of a plugin that is already installed, WordPress shows “This plugin is already installed” with a Replace current with uploaded button. Use that to update it.
- If the plugin is not listed, open
wp-content/pluginsin your file manager, rename the leftover folder (for example toplugin-name-old) and run the install again. Delete the renamed folder once the new copy works.
The same applies to themes in wp-content/themes.
Step 5: Try the install again
Run the install or update again from the dashboard. If it still fails, try installing with WP-CLI over SSH, which shows clearer errors — including the full path of the folder it could not create:
wp plugin install plugin-slug --activate
Run WP-CLI as the site user — the account that owns the WordPress files, or the user PHP-FPM runs as — never as root. WP-CLI bypasses WordPress’s ownership test entirely, so an install run as root succeeds and then leaves root-owned files behind; the next dashboard update of that plugin fails with this same error. If you are root on the server, switch user first, for example sudo -u www-data wp plugin install plugin-slug --activate (replace www-data with your real site/PHP user). Do not use --allow-root as a habit: it silences WP-CLI’s warning without fixing the ownership problem it warns about.
If the update stopped part-way and the site shows a maintenance message, see Briefly unavailable for scheduled maintenance.
Tracing the failure in WordPress itself (for the curious)
You do not need this section to fix the error. It is here so you can see where the message comes from instead of guessing.
The words “Could not create directory.” are defined in wp-admin/includes/class-wp-upgrader.php, in the upgrader’s list of messages. The failure itself happens in copy_dir() in wp-admin/includes/file.php. That function copies the unzipped package out of wp-content/upgrade/ into its destination — wp-content/plugins, wp-content/themes, or a core folder — creating each subfolder as it goes. When a mkdir fails, copy_dir() returns an error whose data is the exact path it tried to create: the destination plus the folder name. So the failing folder can sit deep inside a plugin, not only at the top of wp-content.
The dashboard only shows you the message, not the path. That is why the same error can feel vague: two sites show identical text for two different folders. If you have SSH access, WP-CLI prints the full path, which is the fastest way to find the exact folder:
wp plugin install plugin-slug --activate
Run it as the site user (see Step 5), and read the path in the error — then check that folder’s owner with ls -ld, as in “Why permissions can look right and still fail” above. The other places the same message can come from are the two unzip paths (_unzip_file_ziparchive() and _unzip_file_pclzip() in the same file.php), which is why a full disk can wear the same disguise — see the cron-only disk check in Step 1.
When to contact your host
Contact your host if disk space is fine and permissions look right but WordPress still cannot write files, if files are owned by a different user, or if the problem started after a server move. Ask them to check ownership of the WordPress folder and that PHP runs as your account.
Frequently asked questions
Why did this start after a migration?
Copying files with a different user, or restoring an archive as root, often leaves files owned by the wrong account. Permissions then look correct but WordPress still cannot write. Our migration guide covers the full move.
Is it safe to give WordPress my FTP password?
It works, but it is a sign of an ownership problem. Fixing ownership is better than storing FTP details.
Does this affect automatic updates?
Yes. Background updates use the same upgrader, so they are affected too. If WordPress cannot write files directly, plugin and theme auto-updates are skipped without an email; other failures usually send an update-failure email to the administration address. Our auto-updates guide explains how to check them.
I set everything to 777 and it still fails. Why?
Because the problem is ownership, not permissions. 777 changes what everyone may do; it does not change who owns the folder. If PHP runs as one account and the folder belongs to another, WordPress’s ownership test still fails — and the FTP prompt, or this error, stays. Set the folders back to 755 and the files to 644, then fix the owner (Step 3, and “Why permissions can look right and still fail” above).
Why does the error not say which folder it could not create?
The dashboard shows only the message text. The folder path is attached to the error inside WordPress (copy_dir() returns the destination plus the folder name), but the dashboard does not display it. WP-CLI does print the full path — see “Tracing the failure in WordPress itself” above.
My disk is not full, but WordPress says I may have run out of disk space. Why?
That message appears whenever the unzip or copy step fails for space reasons — and “space” here includes the inode (file-count) limit and your account quota, not just gigabytes used. Also, WordPress only checks free space in advance during automatic (cron) updates; a manual update hits the failure later, at the write. Check disk and inode usage in your hosting panel, and clear old backups stored inside the account first.
It worked yesterday. What changed?
Something changed ownership or filled the disk. The usual suspects: a migration or restore done as the wrong user, a plugin installed or updated over SSH as root, a host move that changed which account PHP runs as, or backups and old update leftovers piling up inside the account until it hit its limit. If nothing on the site changed, ask your host whether anything changed on the server side — PHP user, ownership, or quota.
Related guides
- Back up a WordPress site — back up files and database before changing ownership or permissions.
- Roll back a WordPress plugin update — if an update fails part-way and you need the previous version back.
- WordPress debug log — if the install fails without a clear message, the debug log is the next place to look.
- WordPress missed schedule / WP-Cron — if automatic updates never run, so the cron-only disk check never gets a chance to warn you.
- Verify WordPress core files — if a core update reports files that could not be copied.
Summary
“Installation failed: Could not create directory” means WordPress could not write to its plugin, theme or upgrade folders. Check disk space, set folders to 755 and files to 644, make sure files belong to the account PHP runs as, clear leftover folders for “Destination folder already exists”, and avoid 777 permissions.