Knowledge
Laravel failed to open stream: Permission denied
#Laravel
A blank page or 500 error right after deploying is almost always a permission problem on the storage or bootstrap/cache directory. Here is how to fix the ownership properly.
Published by Mark van Eijk on June 23, 2026 · 1 minute read
About the error
You'll find a line like this in your log, or on screen with debug enabled:
file_put_contents(/var/www/storage/logs/laravel.log): Failed to open stream: Permission denied
The path varies, it might be storage/framework/views, storage/framework/cache, or bootstrap/cache, but the cause is always the same: PHP tried to write a file and the operating system said no.
Why do I see this error
Laravel needs to write to a few directories while it runs: logs, compiled Blade views, the framework cache and the config/route cache. If the user running PHP-FPM (usually www-data) does not own those directories, every write fails.
This bites most often right after a deploy or a git clone, because the files were created by your own user (or by root), not by the web server user. The daily log channel is a common trigger: whichever process writes the first log line of the day owns that file, and the other process then can't append to it.
Solution
Give ownership of the writable directories to the web server user and set sensible permissions:
sudo chown -R www-data:www-data /var/www/storage /var/www/bootstrap/cache
sudo chmod -R 775 /var/www/storage /var/www/bootstrap/cache
Replace www-data with nginx on RHEL/CentOS based systems, and adjust the path to your project root.
If your deploy user and the web server user are different, add your deploy user to the web server group so both can write:
sudo usermod -aG www-data deployer
After fixing permissions, clear any half-written cache files:
php artisan optimize:clear
See clearing the cache in Laravel for what that command does.
A few warnings
- Never use
chmod 777. It lets any user on the server write to your application files, which is a real security risk.775with the correct group ownership is enough. - On RHEL, CentOS or Fedora with SELinux in enforcing mode, correct Unix permissions still aren't enough. You also need the right SELinux context:
sudo chcon -R -t httpd_sys_rw_content_t /var/www/storage /var/www/bootstrap/cache
With debug off, this error reaches visitors as a generic 500 Internal Server Error. The same kind of permission problem on the web root itself (rather than storage) instead produces a 403 Forbidden in nginx.
Subscribe to our newsletter
Do you want to receive regular updates with fresh and exclusive content to learn more about web development, hosting, security and performance? Subscribe now!
Related articles
How to use different PHP versions with Laravel Valet
A blank page or 500 error right after deploying is almost always a permission problem on the storage or bootstrap/cache directory. Here is how to fix the ownership properly.
Disable cookies in Laravel
A blank page or 500 error right after deploying is almost always a permission problem on the storage or bootstrap/cache directory. Here is how to fix the ownership properly.