In short
The Laravel storage permission denied error means the user running the web server can't write to the storage and bootstrap/cache directories, and it usually shows up as a blank 500 page. On cPanel hosting, set directories to 755 and files to 644 and make sure your own user owns them; on a VDS, make those directories writable by the web server group. A missing APP_KEY and a stale config cache cause the same symptom.
In this guide
- First, see the real error
- Quick diagnosis by error message
- 1. Correct permissions on cPanel hosting
- 2. Correct permissions on a VDS (Nginx + PHP-FPM)
- 3. Missing storage directories
- 4. Missing APP_KEY
- 5. storage:link problems
- 6. Errors caused by the config cache
- Deployment habits that keep the error from coming back
- Checklist
- Next step: an environment without permission headaches
The Laravel storage permission denied error means the user running PHP can't write to the storage or bootstrap/cache directories. Laravel writes logs, sessions, compiled Blade views and cache files there; when it can't, you usually get a bare 500 Internal Server Error page. The fix is most often correct file ownership and correct permissions, but a missing APP_KEY, a broken storage:link and a stale config cache produce the same 500 error. Work through the steps below in order and you'll find the cause in a few minutes.
First, see the real error
A 500 page is a symptom, not a diagnosis. The actual message is in one of two places:
- Laravel log:
storage/logs/laravel.log(orlaravel-YYYY-MM-DD.logif you use the daily log channel) - Web server / PHP error log: If Laravel can't even write to its log file, the error only shows up here. In cPanel you can read it under Errors or in the
error_logfile in the project root.
Check the last lines over SSH:
tail -n 50 storage/logs/laravel.log
For temporary troubleshooting you can set APP_DEBUG=true in .env, but on a live site switch it back to false as soon as you're done; otherwise environment variables and queries can be exposed to visitors. You'll find general log-reading techniques in our article on cPanel access and error logs.
Quick diagnosis by error message
| Message | Cause | Section |
|---|---|---|
The stream or file "storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied | No write permission on the log directory, or the file belongs to another user | Permissions |
file_put_contents(.../storage/framework/views/...): Failed to open stream: Permission denied | The compiled views directory isn't writable | Permissions |
Please provide a valid cache path. | The storage/framework subdirectories are missing | Missing directories |
The bootstrap/cache directory must be present and writable. | bootstrap/cache is missing or not writable | Permissions |
No application encryption key has been specified. | APP_KEY is empty | APP_KEY |
| Uploaded images return 404 | The public/storage link is missing or points to the wrong place | storage:link |
.env changes have no effect, env() returns null | Stale config cache | Config cache |
1. Correct permissions on cPanel hosting
On cPanel hosting with LiteSpeed or suEXEC-based setups, PHP runs as your own cPanel user. So if you own the files, 755 on directories and 644 on files is enough. Run these commands in the project root:
find storage bootstrap/cache -type d -exec chmod 755 {} +
find storage bootstrap/cache -type f -exec chmod 644 {} +
Don't use 777. Making files world-writable is a security hole; on top of that, some suEXEC and LiteSpeed configurations refuse to execute group- or world-writable PHP files and directories, which produces exactly a 500 error. That's usually why "I set 777 and the error got worse" happens.
If you uploaded the files over FTP from another account or extracted them from an archive, the ownership may be different. Check it:
ls -la storage storage/logs bootstrap/cache
If the owner column shows a user other than your cPanel username (for example root or nobody), you can't change the ownership yourself; open a support ticket and ask for it to be fixed.
2. Correct permissions on a VDS (Nginx + PHP-FPM)
On your own server, PHP-FPM usually runs as the www-data user, while you deploy code as your own user. The cleanest fix is to make your deploy user the owner of the files and the web server group their group:
sudo chown -R $USER:www-data storage bootstrap/cache
sudo chmod -R ug+rwX storage bootstrap/cache
sudo find storage bootstrap/cache -type d -exec chmod g+s {} +
The setgid bit on the last line makes newly created files inherit the www-data group too.
The classic trap: running artisan as root
If you run sudo php artisan ... or run artisan from root's cron on a VDS, the log and cache files created that day are owned by root and the web server can't write to them. Because the error shows up at midnight when a new log file is created, it looks random. Always run artisan commands and cron jobs as the application's user:
sudo -u www-data php artisan cache:clear
SELinux on AlmaLinux and Rocky Linux
On RHEL-based distributions, if you still get permission denied even though the permissions are correct, SELinux may be the cause. If getenforce returns Enforcing, allow the web server to write to these directories through the SELinux context:
sudo chcon -R -t httpd_sys_rw_content_t storage bootstrap/cache
For a permanent rule, use semanage fcontext and restorecon. Turning SELinux off entirely hides the problem but also disables a security layer.
3. Missing storage directories
Empty directories under storage sometimes don't make it into the Git repository because of .gitignore. Laravel expects these directories:
mkdir -p storage/framework/cache/data storage/framework/sessions storage/framework/views storage/logs storage/app/public bootstrap/cache
Then reapply the permission commands from section one or two.
4. Missing APP_KEY
APP_KEY is the key Laravel uses for sessions and encrypted data. If you copy .env.example to a new server and forget to generate a key, every request returns a 500.
php artisan key:generate
Warning: Don't change the key of an application that's already live. If the key changes, existing sessions are dropped and database fields encrypted with encrypt() can no longer be decrypted. If you're migrating, copy the APP_KEY value from the old server exactly.
5. storage:link problems
php artisan storage:link creates a symbolic link from public/storage to the storage/app/public directory. If uploaded files return 404, there are three likely causes:
- The link doesn't exist: Run the command in the project root.
- The document root is different: If your cPanel site is served from
public_htmland Laravel'spublicdirectory was copied there, the link gets created in the wrong place. Create the link manually in the actual document root. - The link broke after a migration: The symbolic link may point to an absolute path on the old server. Delete it and create it again.
ls -l public_html/storage
rm public_html/storage
ln -s /home/kullanici/proje/storage/app/public /home/kullanici/public_html/storage
If you get symlink() has been disabled for security reasons, PHP's symlink function is disabled; the ln -s command above does the same job over SSH. The cleanest fix, though, is to point the domain's document root directly at the project's public directory; see our guide on deploying a Laravel project to cPanel hosting.
6. Errors caused by the config cache
When you run php artisan config:cache, Laravel writes the entire configuration to bootstrap/cache/config.php and stops reading the .env file. Two typical results:
- You changed the database password in
.env, but the app still tries to connect with the old one. - You called
env('...')directly in code outside theconfig/files, and after caching the value returnednull.
A cache file generated on another server can also cause permission denied errors because it carries that server's absolute paths. Clear the caches and rebuild them:
php artisan optimize:clear
php artisan config:cache
php artisan route:cache
php artisan view:cache
If even artisan won't run, delete bootstrap/cache/config.php manually and try again.
Deployment habits that keep the error from coming back
Permission errors are often fixed once and then come back with the next update. The reason is usually that the deploy steps are done differently each time. A short script that follows the same order on every update breaks that cycle:
#!/bin/bash
set -e
cd /home/kullanici/proje
git pull
composer install --no-dev --optimize-autoloader
mkdir -p storage/framework/cache/data storage/framework/sessions storage/framework/views storage/logs bootstrap/cache
find storage bootstrap/cache -type d -exec chmod 755 {} +
php artisan migrate --force
php artisan optimize:clear
php artisan optimize
Save the script as deploy.sh and make it executable with chmod +x deploy.sh. A few more rules:
- Don't commit
vendor, the logs instorageorbootstrap/cache/*.phpfiles to Git; cache files generated on another machine carry the wrong paths. - If you upload files from your local computer as a zip, extract the archive on the server over SSH; some FTP clients can mangle permissions.
- On a VDS, add cron jobs to the application user's crontab, not root's.
Checklist
- Read
storage/logs/laravel.logand the server error log. - Confirm that the
storageandbootstrap/cachedirectories exist and are owned by the correct user. - On hosting, apply 755/644; on a VDS, apply user:www-data and
ug+rwX. Don't use 777. - Check that
APP_KEYis set. - Reset the caches with
php artisan optimize:clear. - If images won't load, recreate the
public/storagelink.
Laravel's official deployment documentation summarizes directory permissions and optimization commands.
Next step: an environment without permission headaches
Most Laravel permission errors come from not knowing which user PHP runs as. Sunucu Atlas Laravel hosting plans include cPanel Terminal/SSH access, Composer and Git alongside the LiteSpeed web server, so you run artisan commands and deployments as your own account, the same one that owns the files. For projects that generate a lot of logs and cache, SA-DEV-3 with 4 GB of RAM and 80 GB of NVMe storage is a good fit; for teams running multiple projects that want direct access to access/error logs, SA-DEV-4 with 8 GB of RAM is the right choice. If you run into permission issues during a migration, open a support ticket.
Frequently asked questions
Should I set the Laravel storage folder to 777?
No. 777 makes files writable by everyone, which is a security risk, and on some suEXEC/LiteSpeed configurations it causes a 500 error. On cPanel hosting, 755 for directories and 644 for files is enough.
Why does Laravel return a 500 error but write nothing to the log file?
If Laravel can't write to its log file, the error only appears in the web server or PHP error log. Check the cPanel Errors section or the error_log file in the project directory; the cause is usually storage permissions.
Can I run php artisan key:generate on a live site?
Don't run it on a working site; when the key changes, sessions are dropped and encrypted data can't be decrypted. Use it only when APP_KEY is empty or during the initial install, and copy the old key when migrating.
I ran storage:link but images still won't load. What should I do?
The link is most likely not in the site's actual document root, or it points to the old server's path. Check it with ls -l and recreate it in the correct document root with ln -s.
I changed the .env file but Laravel still uses the old settings. Why?
When the config cache is active, Laravel doesn't read the .env file. Run php artisan config:clear or optimize:clear, then rebuild it with config:cache if needed.