Fix for WordPress unable to create uploads directory or not writable by server

This is a note to future self as much as anything, but hopefully useful for someone out there.

Situation: uploads are failing with “Unable to create directory uploads. Is its parent directory writable by the server?”

Unable to create directory - is its parent diectory writable by server?
Yeah this screenshot is from an older WP version :)

Check the following:

  1. wp-content/uploads is chmod -R 777 (for testing, switch to something more secure after you get this sorted)
  2. You’ve got the correct userids (you tested both chown -R www-data:www-data and userid:userid).
  3. You don’t have UPLOADS defined in wp-config
  4. Did you move this database from another server?

This last was the one that got me today. So:

Check the database:

wp db cli (I use wp-cli)
mysql> select * from wp_options where option_name like ('%upload_path%');

Is your upload_path set up for the old server filesystem? If not, sorry you need to check something else.

If so,  update it with this:

mysql> UPDATE wp_options SET option_value = replace(option_value, '/old/path/to/wp-content/uploads', '/new/path/to/wp-content/uploads') WHERE option_name = 'upload_path';

I hope that helps save someone an hour or so of head-scratching. Don’t forget to set your permissions back to something reasonably secure afterwards.

Please let me know in the comments if this helped you out.

Leave a Reply