Skip to content

Fix this error

Laravel: storage/logs/laravel.log could not be opened: Permission denied

Dasun Kalupahana 197 views

The error

Error

The stream or file "/var/www/html/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied

Why it happens

The web server user (often www-data, nginx or apache) cannot write to storage/ or bootstrap/cache/. This happens after uploading files as another user, running artisan as root, or extracting a zip that kept the wrong permissions.

How to fix it

  1. Give the web server user ownership of the two writable folders.
  2. Make them writable for the owner and group (775, not 777).
  3. On shared hosting (cPanel), set the folders to 755 or 775 in File Manager; files run as your own user there.
sudo chown -R www-data:www-data storage bootstrap/cache
sudo chmod -R 775 storage bootstrap/cache
Still stuck? Send us the full error and what you tried. We add the answers here.

Learn more on the blog

Get new articles in your inbox

Practical tutorials and deep dives, about once a week. No spam, unsubscribe anytime.

Privacy policy

Add DEV Talk to your Home Screen

  1. 1 Tap the Share button in Safari's toolbar.
  2. 2 Scroll down and tap Add to Home Screen.
  3. 3 Tap Add. Open it from the Home Screen to read like an app and to turn on notifications with the bell.

We use cookies to improve your experience and analyze traffic. By continuing, you agree to our Privacy Policy.