Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

A file in storage/app/public returns 403 Forbidden

Error403 Forbidden for /storage/photos/image.jpg

Short 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.

  • Applies to Laravel 11, Laravel 12, PHP 8.3, Ubuntu 24.04
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 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/photos
  2. 2Match what you see, then jump to its fix

    1. 1ls shows -rw------- on the file.The file was stored with private visibilityFix
    2. 2The file is 0644 but the folder above it shows drwx------.The permissions map was changed, or a directory is 0700Fix

What does the error look like?

  • 403 Forbidden for /storage/photos/image.jpg
  • The 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/photos

2Fix

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/photos

Confirmed by laravel.com

Did this fix it?

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.php

2Fix

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/photos

Confirmed by laravel.com

Did this fix it?

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

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 fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.