Laravel storage 🐘 PHP

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

The web server can’t write to Laravel’s storage or bootstrap/cache directories.

Seen on: PHP

Meaning

Laravel writes logs, compiled views, sessions and cache to storage/ and bootstrap/cache. Files created by a different user (deploying or running artisan as root) leave them unwritable for the web server.

Common causes

  • storage/ owned by root after running artisan with sudo
  • Deploy user differs from PHP-FPM user
  • SELinux context

⚡ Quick fix

  1. sudo chown -R www-data:www-data storage bootstrap/cache
  2. chmod -R ug+rw storage bootstrap/cache
  3. Run artisan as the web user: sudo -u www-data php artisan …

Detailed fix by platform

Linux

  1. SELinux: chcon -R -t httpd_sys_rw_content_t storage bootstrap/cache

How to diagnose

  1. Owner — ls -l storage/logs
  2. User — Which user runs PHP-FPM?

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.