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

**Code:** `Laravel storage` · **Category:** PHP · **Seen on:** PHP

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

## 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?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/php/laravel-storage-permission-denied)
