# laravel.log could not be opened in append mode: Permission denied

The user PHP runs as cannot write to storage/logs/laravel.log. Fix the owner and group of storage and bootstrap/cache, never chmod 777.

Message:

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

Exception:

```text
UnexpectedValueException
```

## What it means

Laravel's file log, which runs on Monolog, tried to open `storage/logs/laravel.log` to add a line, and the operating system refused. The user PHP runs as may not write to that file, or may not create it in `storage/logs`. Monolog throws an `UnexpectedValueException` and adds the message it failed to write after "The exception occurred while attempting to log:". Laravel then tries to log that failure and fails again, so the message repeats, and the last of those lines holds the error you were originally trying to log.

## Why it happens

- The log file belongs to another user. Whoever writes the first line creates the file and owns it. When a cron job, a queue worker or an `artisan` command run as root or as your deploy user creates `laravel.log`, the file gets permission `0644`, which the docs list as the default for the `single` and `daily` channels. The web server's PHP user can read it but not append to it. With the `daily` channel this can return every day, because each day starts a new file.
- `storage` belongs to the wrong user. After an upload or a `git clone` as another user, PHP cannot create files in `storage/logs` at all, and the message is the same. The deployment docs say Laravel must be able to write to `storage` and `bootstrap/cache`.

## How to fix it

See who owns the files, and compare with the user your PHP-FPM workers run as:

```bash
ls -l storage/logs
ps aux | grep php-fpm
```

Give the files to your deploy user and the web server's group, let that group write, and make new files inherit the group. This example assumes a `deploy` user and the `www-data` group:

```bash
sudo chown -R deploy:www-data storage bootstrap/cache
sudo chmod -R ug+rwX storage bootstrap/cache
sudo find storage bootstrap/cache -type d -exec chmod g+s {} +
```

Then let Laravel create log files that the group can write, with the `permission` option of the channel. This excerpt shows the one key to add to your channel in `config/logging.php`:

```php
'single' => [
    // ...
    'permission' => 0664,
],
```

Run the scheduler and queue workers as the same user as the site, not as root, so they never create files the site cannot write.

Do not fix this with `chmod -R 777`. It lets every user and every process on the server write to these folders. `bootstrap/cache` holds PHP files that Laravel loads on every request, so anyone who can write there can run code as your application.

## Find it in production

The visitor gets a 500 response, but only on requests that write to the log. In a test, a page that logged nothing still answered 200, while a page that logged a line or threw an exception answered 500 with the plain "Server Error" page.

Only the log line is lost. `laravel.log` stops growing, but Laravel runs the handler's report callbacks before it writes the log line. An error tracker that hooks into the handler still receives the original exception, and then the `UnexpectedValueException` too. That holds unless the tracker buffers in a file cache under the same mis-owned `storage` directory. [Ranetrace error monitoring](/features/error-monitoring) receives what the handler reports. Its buffer uses the app's cache store, so with a file cache in that directory it fails as well.

Without a tracker, look for 500 responses in your web server's access log, and check when `laravel.log` last changed.

Reproduced on Laravel 13.45, PHP 8.5, 5 December 2026.

Read more: https://laravel.com/docs/logging

## Related

### Terms

- [Task scheduling in Laravel](https://ranetrace.com/glossary/task-scheduling-in-laravel.md)
- [Queues in Laravel](https://ranetrace.com/glossary/queues-in-laravel.md)

### Other errors

- [No application encryption key has been specified](https://ranetrace.com/error-guides/laravel-no-application-encryption-key.md)
- [Vite manifest not found at: public/build/manifest.json](https://ranetrace.com/error-guides/laravel-vite-manifest-not-found.md)

Read this guide in a browser: https://ranetrace.com/error-guides/laravel-log-file-permission-denied
