Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mcload's avatar

Permission denied in /storage

I have a project that was previously working, and when I tried to open it today, I got the following errors.

Unable to create lockable file: /var/www/storage/framework/cache/data/15/ed/15ed45fc33a4af8dc4baab88de709b23759e5b28. Please ensure you have permission to create files in this location

Which then further expanded with: The stream or file \"/var/www/storage/logs/laravel.log\" could not be opened in append mode: Failed to open stream: Permission denied

The project is running in docker, my storage folder is 777 and is owned by root:www-data.

root@5090cb912799:/var/www/storage/logs# ls -lsa
total 232
  4 drwxrwxrwx+ 2 root www-data   4096 Dec  6 13:56 .
  4 drwxrwxrwx+ 5 root www-data   4096 Jul 26  2023 ..
  4 -rwxrwxrwx  1 root www-data     14 Jul 26  2023 .gitignore
220 -rwxrwxrwx  1 root www-data 220713 Dec 20 16:53 laravel.log
root@5090cb912799:/var/www/storage# ls -lsa
total 20
4 drwxrwxrwx+  5 root www-data 4096 Jul 26  2023 .
4 drwxr-s---+ 14 root www-data 4096 Dec 20 13:32 ..
4 drwxrwxrwx+  3 root www-data 4096 Jul 26  2023 app
4 drwxrwxrwx+  6 root www-data 4096 Jul 26  2023 framework
4 drwxrwxrwx+  2 root www-data 4096 Dec  6 13:56 logs

I tried rebuilding the container and php artisan cache:clear too.

When I search for this error only these ideas are coming up. What else can cause it?

0 likes
2 replies
tisuchi's avatar

@mcload It seems it's an issue with the user accessing the storage directory.

Set user in docker service:

In your docker-compose file, update your service like this:

services:
  app:
    user: "www-data"

Correct File Ownership

Try changing the ownership of the storage and bootstrap/cache directories to the user under which the web server runs, typically www-data:

chown -R www-data:www-data /var/www/storage
chown -R www-data:www-data /var/www/bootstrap/cache

Don't forget to clear your cache.

Christofer's avatar

Laravel has default permissions for folders and files that should not be a problem.

I do have an issue when I run CLI/Cron/artisan commands that write the first log entry to a file, that file has completely different user and permissions that breaks things. Not sure how to solve this yet. But I thought I'd mention it as it may be also happening to you.

Please or to participate in this conversation.