How to Fix “Permission denied: laravel.log” Error (Laravel)
web-application-framework laravel
This article explains how to resolve the error:
“The stream or file “laravel.log” could not be opened in append mode: Failed to open stream: Permission denied.”

Prerequisite
- You have a Laravel project.
For running a Laravel project with NGINX, refer to “Running a Laravel Project with NGINX”.
Environment
- Windows 11
- Ubuntu 24.04.3 LTS (WSL2 distribution)
- Docker Engine 28.4.0
- Amazon Linux 2023(OS of the Docker container)
- PHP 8.2.15 (fpm-fcgi)
- NGINX 1.24.0
- Laravel 11, 12
Fix Permission
Check the permissions of the laravel.log file’s directory.
You can find the directory path in the logging configuration.
In this example, the directory is storage/logs.
drwxr-xr-x root root logs
Currently, only the root user can write log files.
To allow the nginx user to write them, change the owner of the directory to nginx:
$ chown -R nginx:nginx storage
Verify the updated permissions:
drwxr-xr-x nginx nginx logs
Then check whether the error has been resolved.
Change PHP-FPM User
If the error persists, check the PHP-FPM user in the www.conf file, usually located in the /etc/php-fpm.d directory.
If the user is different from nginx (e.g., apache), change it to nginx and restart PHP-FPM:
[www]
user = nginx
group = nginx
Related articles
- How to Fix “Permission denied: laravel.log” Error (Laravel)
- How to Generate and Display QR Codes with Laravel and React (qrcode.react)
- How to Run Code After a Successful Stripe Payment Using Webhooks
- Install Laravel Cashier (Stripe)
- Why the 419 Error Is Thrown When Using Fetch in Laravel?
- Laravel + shadcn/ui Pagination
- Interacting with PostgreSQL from a Laravel Project
- Inertia.js + shadcn/ui Form on Laravel
- Set Up Laravel with a React Project
- Install Bootstrap in a Laravel Project