The day before, I updated a new module and it was working normally. Now, when I run bin/magento setup:upgrade, I receive the below Exception. I tried setting permissions to 777 (or 770) for the pub folder in Magento 2 but it is not working.

  Missing write permissions to the following directories: 'pub/static'

  • did u manage to resolve this problem ? if so pls post the solution. Commented Dec 2, 2015 at 12:40
  • Are you have same issue ?
    – LinoPham
    Commented Dec 2, 2015 at 13:05
  • yes i am facing the same issue. how did u resolve it ? Commented Dec 2, 2015 at 13:26
  • I comment some line code in core. Are you want do as me?
    – LinoPham
    Commented Dec 2, 2015 at 13:28
  • 1
    i posted my relsove in post below. I can try with it
    – LinoPham
    Commented Dec 2, 2015 at 13:35

15 Answers 15


TL;DR truncate pub/static folder.

For me, I had an older installation, which probably had some symlinks and old files which no longer exist.

The issue checkInstallationFilePermissions is that it checks the permissions recursively. Files and folders. I had a missing symlink, and that returned false on the check if it's writable.

How to debug:

  1. setup/src/Magento/Setup/Model/FilePermissions.php

  2. Goto line 143 in method checkRecursiveDirectories

  3. Add the lines var_dump($subDirectory);var_dump($subDirectory->isWritable());

  4. Re run bin/magento setup:upgrade

now you'll see what is really wrong, and you can fix it. Personally i remove everything in pub/static, this will be auto generated content so you should not be worried about that.

  • 1
    I removed pub/static completely, after I ran setup:upgrade the only folder inside pub/static is __requirejs folder. Css are missing, no styling what so ever.... Man.. do I wish i haven't done that Commented Feb 17, 2016 at 16:13
  • how can I restore everything in pub/static ? Commented Feb 17, 2016 at 16:34
  • 2
    everything was going so well.... :) i really start to despise this framework Commented Feb 17, 2016 at 17:11
  • 3
    If you remove the contents of pub/static just make sure you don't remove pub/static/.htaccess as it is part of the code base and doesn't get recreated: github.com/magento/magento2/tree/2.0/pub/static
    – mttjohnson
    Commented Jun 8, 2016 at 15:24
  • Perfecto! This was it..
    – Arvind07
    Commented Jul 10, 2016 at 10:45

I ran into this error in development because of a broken symbolic link.

I had created a file in a module's view/frontend/web directory that in developer mode was deployed to the pub/static directory using a symbolic link that pointed to the module's directory where the original file is stored.

At some point in development I removed the file from my module, but the symbolic link still existed in pub/static pointing to a file that no longer existed. I expect this would also be the case if I had renamed one of the files.

If a site is in production mode and has had bin/magento setup:static-content:deploy run, that actually copies the files to the pub/static directory instead of creating symbolic links.

In order to find this broken symbolic link I ran a command from the shell

find -L . -type l

Removing the broken symbolic link resolved the problem (for example using find -L . -type l -exec rm {} \;).

  • This was the answer to my issue as well, thanks mttjohnson! Commented Jul 6, 2016 at 14:15

Inside your Magento root directory run the commands below and your issue should be gone:

$ rm -rf pub/static/*
$ php bin/magento setup:static-content:deploy

Worked for me.

  • This will delete .htaccess file too. You need .htaccess file. Commented Nov 4, 2019 at 7:50
  • 1
    @AdarshKhatri no it won't. rm -rf pub/static/* doesn't delete dotfiles. Go ahead and try with a test directory. rm -rf pub/static/.* (notice the dot) would delete htaccess.
    – Erik B
    Commented Jul 22, 2020 at 22:45
  • @medina Thank you 🙏🏻 Commented May 15, 2021 at 11:29

You should setup the permissions as it is described in the official documentation: http://devdocs.magento.com/guides/v2.0/install-gde/install/file-system-perms.html

  • 1
    can you the actual permissions just cause in-case the url changes.
    – rob3000
    Commented Nov 23, 2015 at 8:27
  • I try again but it not working
    – LinoPham
    Commented Nov 23, 2015 at 8:31
  • Do not forget to do it recursively into subdirectories: pub, pub/static, etc. Commented Nov 23, 2015 at 8:33
  • ownership is as important as permissions; check the above link and also devdocs.magento.com/guides/v2.0/install-gde/prereq/…. You must have two users; a local user and the web server user Commented Nov 23, 2015 at 15:34
  • the whole idea of setting the permissions at application level is wrong so I think people should avoid the documentation at that section. it will be updated in next versions according to their github issues Commented Apr 4, 2016 at 16:59

This is my resolved temporary. I comment line 744 and 466 in <magento_dir>/setup/src/Magento/Setup/Model/Installer.php.

This is line code:


I need solution don't change core file.

  • The problem is likely due to a broken symlink (answered below) under the pub/static directory. Removing the broken symlink should resolve the problem without modifying core files.
    – mttjohnson
    Commented Jan 7, 2016 at 17:24
  • newtips.co/magento/questions/91184/… This will work Commented Mar 1, 2016 at 6:31
  • @EnvisionEcommerce the link doesn't work.
    – MagePsycho
    Commented Jul 5, 2018 at 7:04

If someone is having this issue on Windows os. Just execute the command on a Administrator command prompt and it will work like a charm. Hope this helps someone.


Fix bin/magento permission denied

chmod u+x bin/magento


These folders needs to have the right permissions like described in: http://devdocs.magento.com/guides/v2.0/install-gde/install/file-system-perms.html

When you remove the contents of the pub/static folder and you give the pub/static folder the permission 770, the message will not show up again.


I had the same problem where i could not install Magento via the command line. Simply creating the folder pub/static solved the problem.


In my case running upgrade command through non-root user or a user with limited permissions was causing the error. Make sure you run the upgrade command with a user with enough permissions.


I verified many times write permissions and everything was good.

  1. I commented this row, which throw me an exception.
  2. Then I ran setup:upgrade.
  3. Reverted back the row with exception
  4. Issue didn't reproduce no more

Run the following command, for the following three IP addresses:

<Magento-Directory>php bin\magento maintenance:allow-ips, 
<Magento-Directory>php bin\magento maintenance:allow-ips "the ip of my localhost given by the NAT-Router" and
<Magento-Directory>php bin\magento maintenance:allow-ips  "the ip of the NAT-Router" 

don't use this :

rm -r pub/static

it will remove all files even .htaccess

you can use this will be better :

rm -rf pub/static/frontend
rm -rf pub/static/adminhtml

after that use :

php bin/magento setup:static-content:deploy en_US -f 

You must have deleted pub/static (except .htacess) under the impression that it will be created upon next execution but after executing upgrade command you ended with this :)

Don't worry, execute the deploy command using -f to have everything in flow and expected.

I had the same issue but managed my old working source by following the above trick.


just remove pub/static folder from your magento2

rm -r pub/static

then deploy static content of magento2

php bin/magento setup:static-content:deploy

by using this process my same problem solved.

  • 5
    You shouldn't remove the entire pub/static directory as it contains a .htaccess file that is important, and the .htaccess file will not get recreated on any static content deploy. You could run rm -r pub/static/* and that should avoid removing the .htaccess file.
    – mttjohnson
    Commented Jan 7, 2016 at 17:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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