A file in storage/app/public returns 403 Forbidden
403 Forbidden for /storage/photos/image.jpgShort answer
A 403 on a file behind public/storage usually means the web server user may not read it. Laravel maps private visibility to 0600 files and 0700 directories on the local driver. A file stored without public visibility, or a changed permissions map, produces exactly that.
Fix it fast
1Find out which cause you have
Look at the permissions of the file and its folders, and at who owns them.
ls -l storage/app/public/photos2Match what you see, then jump to its fix
What does the error look like?
403 Forbidden for /storage/photos/image.jpgThe file exists in storage/app/public but the browser cannot open it
Cause 1 of 2
The file was stored with private visibility
1Check
On the local driver, private visibility means 0600 for files, so only the owner can read it. A file written by a different user than the web server's user cannot be served.
ls -l storage/app/public/photos2Fix
Set the file's visibility to public, and store future files as public.
Storage::disk('public')->setVisibility('photos/image.jpg', 'public');
$path = $request->file('photo')->storePublicly('photos', 'public');3Verify
The file mode becomes 0644 and the URL opens.
ls -l storage/app/public/photosConfirmed by laravel.com
Cause 2 of 2
The permissions map was changed, or a directory is 0700
1Check
Public visibility is 0755 for directories and 0644 for files unless the permissions array of the disk overrides it.
grep -n -A12 "permissions" config/filesystems.php2Fix
Restore the public values in the disk's permissions array, then fix the existing folder once.
'permissions' => [
'file' => ['public' => 0644, 'private' => 0600],
'dir' => ['public' => 0755, 'private' => 0700],
],3Verify
Open the file URL after fixing the folder mode.
chmod 755 storage/app/public/photosConfirmed by laravel.com
How do I stop it coming back?
- Run queue workers and web processes as the same user, or files written by one cannot be read by the other.
- Use storePublicly or the public disk for files that must be reachable from the browser.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Back end
Uploaded images return 404 after deploying a Laravel app
Storage::url() returns a link that opens a broken image
Files in storage/app/public are only reachable from the web through a symbolic link at public/storage.
3 causes, each with a fixBack end
Composer says the gd extension is missing on a Laravel project
composer install or composer update stops on a package that requires ext-gd
Composer refuses to install a package that requires ext-gd when the PHP binary running Composer has no GD extension.
4 causes, each with a fixBack end
Why a Filament panel feels slow on a Laravel server
The panel is fast on a small demo and slow once there are many resources, pages and widgets
A slow Filament panel on a server is most often running without the production caches.
3 causes, each with a fixBack end
Intervention Image will not save the file in a Laravel app
Can't write image data to path (/var/www/app/public/uploads/photo.jpg)
Intervention Image writes straight to a file path.
3 causes, each with a fixBack end
Laravel file upload returns 413 behind nginx
413 Content Too Large
A 413 means a limit refused the request body before Laravel could use it.
3 causes, each with a fixBack end
Laravel says the bootstrap/cache directory must be present and writable
The /var/www/app/bootstrap/cache directory must be present and writable.
Laravel writes its package manifest into bootstrap/cache and throws when that folder is missing or the current user cannot write to it.
2 causes, each with a fix