WordPress: Unable to create directory wp-content/uploads/. Is its parent directory writable by the server?

Last updated on | 4 replies

If you see one of the following errors relating to the uploads folder:

  1. Unable to create directory wp-content/uploads/. Is its parent directory writable by the server?
  2. The uploaded file could not be moved to wp-content/uploads/

This may indicate a permissions problem with your WordPress uploads directory.

If you don’t have shell access to your web server to set up directory permissions, you may need to contact your web host for support.

If you have shell access, check the permissions for the directory WordPress is attempting to write to. You will need to locate your document root, in this example, our document root is /var/www/html and the WordPress uploads directory is in /var/www/html/wp-content/uploads/. If the uploads folder does not exist, create it.

Let’s check the permission for the uploads directory.

ls -ld /var/www/html/wp-content/uploads/
drwxr-xr-x 5 john john 4096 Feb 11 04:13 /var/www/html/wp-content/uploads/

Above we can see the owner of the directory is john, the person who set up the web server.

We need to change this to www-data. This is the user that owns the Apache/Nginx web server service and will give WordPress the necessary permissions to upload files.

Let’s recursively change the owner for our WordPress uploads directory and sub directories to www-data. Be sure to change /var/www/html/wp-content/uploads to your own uploads directory.

sudo chown -R www-data:www-data /var/www/html/wp-content/uploads

Now if we check the permissions for the uploads directory again, we should see www-data as owner.

ls -ld /var/www/html/wp-content/uploads/
drwxr-xr-x 5 www-data www-data 4096 Feb 11 04:13 /var/www/html/wp-content/uploads/

You should now be able to upload files again in WordPress.

Let me know if this helped. Follow me on Twitter, Facebook and YouTube, or 🍊 buy me a smoothie.

p.s. I increased my AdSense revenue by 200% using AI 🤖. Read my Ezoic review to find out how.

4 replies

Leave a reply

Your email address will not be published.

  1. Hey, thanks for this! I’m trying to set up WordPress self-hosted, and I guess I forgot to set up folder permissions. Unfortunately, I ran into a problem, since it’s asking me for FTP/SFTP credentials. I do use SFTP sometimes, but I use SSH key authentication instead of password authentication for security. Unfortunately, it doesn’t seem like this is an option… What do I do?

    1. I’m not sure exactly where you were seeing the prompt for SFTP credentials, but some general information might help you.

      Do you know the password of your ‘root’ user account, or an admin account you set up on the server? The credentials for one of those accounts should get you in if you’re being prompted for credentials when logging in via SSH.

      Even if you have a key pair set up on the server, you’ll need to know the password for ‘root’ or your admin account once you start connecting to the server. If you’re on Windows, you can use Putty to set your connection up to automatically provide the ‘root’ username and password each time you connect, making it seem like you don’t need the SFTP credentials, for example: https://www.digitalocean.com/community/tutorials/how-to-use-pageant-to-streamline-ssh-key-authentication-with-putty

      But, in a nutshell, that’s what SFTP is. Your SSH keypair, followed by logging in with an account on the server, whether that be ‘root’ or another admin account.

  2. Hello, I wanted to make this command sudo, but it’s not recognized. And I don’t have root access because I am on a shared hosting. What should I do in this situation? Thank you