Fixed WordPress Plugin Update Error: “Could Not Create Directory” on EC2 by Setting Proper File Permissions
Updating plugins in WordPress is usually simple — but if you're running your site on an AWS EC2 instance and see this frustrating error:
Update failed: Could not create directory...
You’re not alone.
In this post, I’ll walk you through how I fixed this error on multiple blog sites hosted on EC2 by applying the correct file permissions. This guide is especially helpful for developers and sysadmins managing WordPress on cloud servers like AWS.
🚫 The Problem
When trying to update a plugin, WordPress throws this error:
Update failed: Could not create directory. /var/www/your-site.com/wp-content/upgrade/plugin-folder
This means WordPress (actually, PHP) doesn’t have permission to create or write to the upgrade
directory.
✅ The Root Cause
Most commonly, this happens when:
- The directory is owned by the wrong user
- Incorrect permissions prevent PHP from writing
- The directory doesn’t exist at all
Even if other sites on the same server work fine, this error can still occur on a specific site if the ownership or permissions are mismatched.
🔧 Step-by-Step Fix (Tested on EC2)
Here’s what I did to solve it for my blog sites:
1. Check Current Ownership and Permissions
ls -ld /var/www/*
ls -ld /var/www/*/wp-content
This will show which user owns each site’s files. I kept ownership as ec2-user
for consistency.
2. Recreate the upgrade
Directory
If the upgrade
folder is missing or restricted, recreate it safely:
sudo rm -rf /var/www/your-site.com/wp-content/upgrade
sudo mkdir /var/www/your-site.com/wp-content/upgrade
sudo chown -R ec2-user:www /var/www/your-site.com/wp-content/upgrade
sudo chmod -R 775 /var/www/your-site.com/wp-content/upgrade
3. Fix File and Folder Permissions
Ensure proper access throughout the project:
sudo find /var/www/your-site.com -type d -exec chmod 775 {} \;
sudo find /var/www/your-site.com -type f -exec chmod 664 {} \;
4. Set Sticky Group Bit (Recommended)
This ensures all new folders inherit the correct group:
sudo chmod g+s /var/www/your-site.com/wp-content
5. Restart PHP and Web Server
sudo systemctl restart php-fpm
sudo systemctl restart nginx
✅ Result
After applying these changes, plugin updates now work smoothly across all sites — no more errors.:
🧠 Pro Tip for Multi-Site Management
If you manage multiple WordPress sites on a single EC2 server:
- Always use a consistent user (e.g.,
ec2-user
) - Set group access to
www
or similar - Use
chmod g+s
on critical folders likewp-content
to prevent future permission issues
📝 Conclusion
This error may look scary, but it’s easy to fix once you understand how permissions work in a Linux environment. By applying the correct ec2-user
ownership and folder permissions, you’ll prevent WordPress plugin update failures and save hours of manual work.