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

Laravel Apr 5, 2023

If you are using docker with or without Laravel Sail, there is a chance that you run into a permission denied issue when installing your Laravel application. This issue can easily be resolved by executing the following commands inside the terminal:

  • chmod -R 775 storage bootstrap/cache (Change folder permissions)
  • sudo chown -R $USER:www-data storage (Change folder owner from root to the currently logged-in user)
  • sudo chown -R $USER:www-data bootstrap/cache (Change folder owner from root to the currently logged-in user)

After executing these commands you can refresh your page and you will see that everything will be working again.


Now you know how to solve this common permission issue.


Solving this permission issue is quite simple and applying this fix will permanently solve this issue within your project. However, this issue can repeat itself if you decide to start another Laravel project using Docker or Laravel Sail. But now you know how to fix this issue.