Skip to main content
📝 WordPress

Fixed WordPress Plugin Update Error: “Could Not Create Directory” on EC2 by Setting Proper File Permissions

Fixed WordPress Plugin Update Error: “Could Not Create Directory” on EC2 by Setting Proper File Permissions Updating plugins in WordPress is usually s...

3 min

Tempo de leitura

464

Palavras

Apr 17, 2025

Publicado

Engr Mejba Ahmed

Escrito por

Engr Mejba Ahmed

Compartilhar Artigo

Fixed WordPress Plugin Update Error: “Could Not Create Directory” on EC2 by Setting Proper File Permissions

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 like wp-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.

Coffee cup

Gostou deste artigo?

Seu apoio me ajuda a criar mais conteúdo técnico aprofundado, ferramentas open-source e recursos gratuitos para a comunidade de desenvolvedores.

Tópicos Relacionados

Engr Mejba Ahmed

Sobre o Autor

Engr Mejba Ahmed

Engr. Mejba Ahmed builds AI-powered applications and secure cloud systems for businesses worldwide. With 10+ years shipping production software in Laravel, Python, and AWS, he's helped companies automate workflows, reduce infrastructure costs, and scale without security headaches. He writes about practical AI integration, cloud architecture, and developer productivity.

Discussion

Comments

0

No comments yet

Be the first to share your thoughts

Leave a Comment

Your email won't be published

16  -  9  =  ?

Continue Aprendendo

Artigos Relacionados

Ver Todos

Comments

Leave a Comment

Comments are moderated before appearing.

Learning Resources

Expand Your Knowledge

Accelerate your growth with structured courses, verified certificates, interactive flashcards, and production-ready AI agent skills.

Sample Certificate of Completion

Sample certificate — complete any course to earn yours