How to Fix the Unable to create directory Error in WordPress

If you are seeing any of the following errors when you try to upload/import media into WordPress’s media library then this tutorial is for you. It will show you how to fix this annoying error.

  • Unable to create directory wp-content/uploads
  • Unable to create directory /wp-content/uploads/ Is its parent directory writable by the server?
  • Unable to create directory wp-content/uploads/2013/02

I personally faced this issue a while back and wrote a quick fix tutorial on this subject. However, a lot has changed since then so it is time to publish an updated version of the tutorial.

There are a few different possibilities for this error to show up. I will try to cover all the possibilities so hopefully one of them will help you fix the issue.

Fix #1: Update/Change the Uploads Directory Settings

This is the easiest option to try and solve this error so you should try this one first.

  1. Log into your WordPress admin dashboard
  2. Go to Media Settings menu (Settings -> Media)
  3. Enter wp-content/uploads in the “Store uploads in this folder” text box
  4. Save the changes by hitting the “Save Changes” button and you are done

wp-media-library-settings-screen

The important thing here is to make sure you only enter the following in the “Store uploads in this folder” field:

wp-content/uploads

Fix #2: Manually Change the Folder Permission

If the above fix doesn’t work then try this option. This method requires you to change the file/folder permissions on your server. If you don’t know how to do this then read the tutorial on how to change permissions.

  1. Change folder permissions on the wp-content directory to 775 and try the upload again
  2. If it fails, change the permissions to 777 and try again
  3. if it still fails then do step 1 and 2 for the “wp-content/uploads” directory too

Once you can successfully create the folder and upload the media, be sure to return the permissions on wp-content directory to 755 (your folders should have a permission of 755 for security reasons).

wp-content-folder-permission-change

Fix #3: Use This If Your Server is Using Ubutu

The webserver (Apache) runs as user www-data and group www-data by default on a Ubuntu system. If the files/folders are not owned by this user (www-data) then the webserver will be unable to write changes to them.

Change the filesystem permission on the folder (where the web application wants to write to) to the “parent directory” as mentioned in the error message.

For example, do (prepend with sudo if you’re not the current owner and need to elevate your own permissions in order to do it):

chown www-data /path/to/directory

to make www-data the owner which makes it writeable usually, or another approach via groups:

chgrp www-data /path/to/directory
chmod g+w /path/to/directory

Fix #4: Try This If Running PHP in Safe Mode

If your server is running PHP in safe mode then know that it won’t allow you to create files or directories if your PHP scripts and upload directories belong to different users. So try one of the following solutions:

  • Change the owner of scripts and upload directories (your hosting provider can do this for you)
  • Disable PHP safe mode (your hosting provider can do this for you)

Fix #5: Use This for XAMPP (LocalHost Installs)

If you have installed XAMPP to run WordPress on your local PC for testing and you are seeing this error then try the following.

Reset the ownership of the WordPress instillation to nobody. You can do this by running the a command in the command line/terminal.

  • Windows System: Start -> Programs -> Accessories -> Command Prompt
  • Mac: Applications ->Utilities -> Terminal
The command you need to run is the following (change “wp” to the actual directory name in your installation):

sudo chown -R nobody:staff /applications/xampp/xamppfiles/htdocs/wp

Hopefully one of the above solutions should help you fix the unable to create directory error in WordPress.

If none of the above solution works then maybe it is time to look for another hosting provider for your WordPress site.

Please feel free to share any other techniques/fixes for this error in the comment section below.

Found this article interesting? Subscribe to Tips and Tricks HQ

email icon rss feed icon twitter icon google plus icon

Comments (22 responses)

  1. Renee says:

    Fix #1 worked beautifully. I had recently changed my hosting and I was trying to upload a plugin when I got that “Unable to create directory… message” I thought I was about to end up spending forever trying to figure it out, but within about 15 minutes I found this site and saw what your readers were saying.

    They were right. Thank you so much. Plain english, wp beginner can understand.

  2. Lily says:

    Thanks you so much!
    I have been searched for solution for a whole day, and Fix #5 really fixed my problems.

    谢谢!

  3. zac says:

    If you need to alter the permissions of ‘wp-content’ folder to 777 to make things work then you need to understand that permissions need to be tweaked.
    You cannot keep 777 which will allow any user to access the folder.

    So always keep your permission to 755 but check the ownership of the folder.
    The owner should be the owner of the service executing the script.
    In the case of a conventional apache service we would have the apache user.

    So,
    $ sudo chown apache:apache -R wp-content

    This should help out!

  4. Hector says:

    Thanks fix #1 worked perfect!!!

  5. S. Chidananda says:

    Thank you very much. I had ubuntu and my www folder was set to “root” user. I changed it to “www-data”. It worked like charm.

  6. Renerio says:

    I knew there was something to it about changing between hosts. I just didn’t know where to look! Obviously Fix#1 from you fixed it.

    Thank you for this!

  7. ankit says:

    Thanks so much for taking the time to share your knowledge. This problem was driving me crazy as it was on a subdomain installation I used your Fix #1 above and all my frustration and stress just simply disappeared. Thanks again for sharing your knowledge.

  8. Sharaj says:

    Thank you so much. The First one worked for my website. Appreciate your cooperation. 🙂

  9. Thanks says:

    Thank you very much. This was the solutions (Fix #1) that worked for my localhost installation with xampp on Windows 7. It’s a pitty that most solutions that you find on google are all about editing code (define(‘FS_METHOD’, ‘direct’);) to the wp-config.php and changing permissions.

  10. Sin says:

    I had the same issue with the latest wp-update. WP nor plugins would auto-update.
    None of the solutions mentioned here worked. What did work was:
    – deactivate all plugins,
    – put the rights all to 777,
    – check for the wp-config (change the rights settings to 0777 there as well)
    – do a manual ftp upgrade of WP,
    – do a auto-upgrade of the still deactivated plugins,
    – reactivate the plugins and
    – put the rights to the previous settings (folders, files and wp-config).
    I don’t know why this works, but it is the second site that had this problem, and it worked twice.

  11. Glenn Bronner says:

    Thanks so much for taking the time to share your knowledge. This problem was driving me crazy as it was on a subdomain installation I used your Fix #1 above and all my frustration and stress just simply disappeared. Thanks again for sharing your knowledge.

  12. Archie says:

    Thank you for publishing this. I found the problem emerged when I changed webhosts. The media settings were specific to my previous host.

    i.e /oldusername/website/wp-content/uploads

  13. Rocky says:

    It worked like a charm. I was wondering for long for this. Thanks

  14. sikander says:

    Fix #1 fixed the problem for me.

    Thanks!

  15. Scott says:

    Thanks for the options to fix this. I had installed an old version of WP a while ago and then updated it recently… after which I was unable to upload images. Your Fix number #1 solved my problem in an instant!! After I spent an hour or so looking around for a solution elsewhere. Many thanks!

  16. Mitch says:

    Thank you for the fix! Worked like a charm.

  17. sue says:

    Thank you for taking the time to post the tips.
    I did your recommended fix #1 which required me to delete a single extra backslash at the beginning of “(/)wp-admin/uploads” and that fixed the frustrating problem. Cheers!

  18. Amy says:

    Thank you so much for this article, fixed my problems right away!

  19. Sam says:

    Thank you very much for this great tutorial. This was easy to understand and i was able to fix this directory creation problem that has been frustrating me for hours.

  20. Arthur says:

    Brilliant Site..Thanx, went through a lot of site but I couldn’t get the help I needed. Found it here…Keep up the good work…

  21. Alan says:

    If your server is running PHP in safe mode then know that it won’t allow you to create files or directories if your PHP scripts and upload directories belong to different users.

Speak Your Mind

*