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

CookieMonster's avatar

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

My application is being deployed to AWS Lightsail(LAMP) and when I try to run artisan migrate it says:

```The stream or file "/opt/bitnami/projects/app-name/storage/logs/laravel.log" could not be opened in append mode: failed to o
pen stream: Permission denied```

What I have tried so far is to allow access to storage via:

```sudo chmod -R 775 storage```

but it is still giving me the error. What seems to be this issue?

0 likes
11 replies
matty-p's avatar

Can you run ls -lah in the /opt/bitnami/projects/app-name/storage/ and /opt/bitnami/projects/app-name/storage/logs directories? There's a couple of things that could be happening here, but it depends on the permissions of the folder and the items in it.

matty-p's avatar

ls is a Linux command that lists directory contents. ls -lah is saying list the directory specified, and specifying the options -lah which say that I want a different formatted output (l), I want to see all files even those starting with "." (a) and that I want output to be human readable (h).

https://man7.org/linux/man-pages/man1/ls.1.html

I want to see what is in the directories and what the permissions are for the files and folders so that I can help you. As a side note, good for you for being wary of a random command given to you by someone on the internet (I didn't even think about how that might come across sketchy to someone new to Linux).

1 like
CookieMonster's avatar

no worries, yea i'm pretty novice to linux/unix system so some commands(even the basic ones like nano/sudo) are foreign to me.

Anyway I managed to fix it as I was only granting permission to via this command:

sudo chmod -R 775 storage

The fix was to add this:

sudo chmod -R ugo+rw storage
27 likes
matty-p's avatar

Ya, I was going to say, your storage folder probably has owner/group set to work with the web server, and your ssh user doesn't own the files or exist in the group.

Just so you know, sudo chmod -R ugo+rw storage is the same as sudo chmod -R 777 storage. 777 and ugo+rw both mean any logged in user can read, write, and execute a given file or folder. If this server is going to be used for a public application, I'd generally recommend you try to lock down your permissions a bit more. Not a requirement per-say, but it's good practice to be as restrictive as you can afford to be.

Happy you solved your issue! Since you're new to Linux, you should check out the man pages for chown and chmod which are directly related to the issue you were having.

http://manpages.ubuntu.com/manpages/trusty/man1/chown.1.html http://manpages.ubuntu.com/manpages/trusty/man1/chmod.1.html

2 likes
mdoulabi's avatar

@CookieMonster tnx solve my problem sudo chmod -R ugo+rw storage what does this commad do? is it risky or some security risk??

Reysa's avatar

@CookieMonster I have a problem , I have to run this command "sudo chmod -R ugo+rw storage" every day when a new log file is created and I don't know why. how can I fix this permanantly?

jenn2000's avatar

@mdoulabi Both commands aim to ensure that the user running the Laravel application (typically the web server, e.g. www-data) has write permissions to the storage folder so that the application can write log files and other data it needs. The first command (chmod -R 775) explicitly sets specific permissions, while the second command (chmod -R ugo+rw) simply adds read and write permissions for all user groups.

noximus's avatar

@CookieMonster thanks! i've been trying to figure this out for hours today! this must be because i am using a VPS!

jaderabbit's avatar

what if,

sudo chmod -R 777 storage

does not work? and still throw the same error?

2 likes
ismaelrak's avatar

@jaderabbit Use chmod 777 its a very bad practice because everyone its gonna have permissions, if someone gain access to your server its gonna have the freedom of do whatever he wants with your project.

Never use this on Production!

7 likes

Please or to participate in this conversation.