This is a weird one.

Wordpress by default stores uploaded media in monthly sub-directories of the uploads directory. Eg wp-content/uploads/2016/07/

On one of my sites, this directory's owner gets set to "root:root", which means that nothing can be uploaded to the directory via the web server.

Any ideas what might cause this behaviour? I can imagine a cron script creating this behaviour, but I don't see how Wordpress itself should be able to create a directory owned by root.

  • Are you running your own web server? If Apache httpd, you probably didnt set the User and Group directives.
    – user42826
    Jul 5 '16 at 16:57
  • 1
    you most likely have some different process that access and change the permissions of the directories. Jul 5 '16 at 17:21
  • This sounds like a server issue and not a wordpress issue. Have you looked on server vault? Jul 5 '16 at 18:13
  • Try to modify your permalinks structure if wp doesn't have permissions to write to your server it would bring up an error, and even if you can modify your .htaccess file via the permalink option menu, that doesn't mean you shouldn't check further permissions. Just disincluding eventual issue.
    – knif3r
    Jul 5 '16 at 19:26

I've had the same problem, and in my case it was the Wordpress cronjob. I was calling the wp-cron.php as a root cron job, and this script also generates the monthly upload folder.

If you call wp-cron.php via cronjob you need to do this as the web server user (or i.e. in Plesk the site user and group psacln). The owner of the created monthly folder is always the user the wp-cron.php is called from.

  • Thank you man! I moved wp cronjobs to crontab and it was causing this. Jul 2 '20 at 15:23

I had the same problem, also a cronjob, but WP CLI was the issue. The cronjob was running a 'wp plugin' command every month, the 'wp plugin' command was creating the monthly folder owned by the same user that ran the cronjob -- root.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.