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

midnightcipher's avatar

Laravel storage goes to 404 page. (Symlink not working)

This is my url:

http://cakeandbake.dev/storage/app/thumbnail/qusrjRoVTlghf2JkSrfHciAMT4j8gycCMv0Rg7XD.jpeg

This should go to an image stored in the storage folder. I have symlinked the folder into my public using

php artisan storage:link

but for some reason it's giving me the 404 page.

This is how I call it inside my view, Am I doing this right?

{{ Storage::url('app/thumbnail/' . $recipe->feature_image) }}
0 likes
20 replies
Snapey's avatar

review the html source for the image, see what was generated

midnightcipher's avatar

alt text

Thats what is generated? I feel like this is not corrected as the "storage" is in the url.

Snapey's avatar

well you should be able to check by just pasting that url into your browser, and removing elements of the path that you think are incorrect

midnightcipher's avatar

Yep already tried that. Unfortunately I cannot figure it out.

Snapey's avatar

show the result of ls public -la

midnightcipher's avatar
midnightcipher
OP
Best Answer
Level 6

I've figured it out. It was the Symlink not working correctly. Following code got it working.

ln -s /Users/ashleybaker/code/cakeandbake/storage/ /Users/ashleybaker/code/cakeandbake/public

NOTE TO OTHERS WITH THIS PROBLEM.

You need to use the full directory path on your system due to the way symlinks work.

Working code:

ln -s /Users/_YOUR_COMPUTER_USERNAME_/_PATH_TO_YOUR_PROJECT_/storage/ /Users/_YOUR_COMPUTER_USERNAME_/_PATH_TO_YOUR_PROJECT_/public

Not working code:

ln -s _PATH_TO_YOUR_PROJECT_/storage/ _PATH_TO_YOUR_PROJECT_/public

What is

php artisan storage:link

This creates a public folder in your storage folder. In my case I did not want this and wanted the symlink the other way around.

1 like
Cronix's avatar

If you symlinked the storage dir to the public dir, then have you just tried /app/thumbnail/qusrjRoVTlghf2JkSrfHciAMT4j8gycCMv0Rg7XD.jpeg for the image url?

buchi's avatar

please is this for deployment or a local project

digitlimit's avatar

I was able to resolve this by running

rm public/storage
php artisan optimize:clear
php artisan storage:link
13 likes
CamKem's avatar

@prashantrai Please do not post reply to old, closed threads. If you have a questions or need help post a new thread to the forum.

msaadm's avatar

In my case I created "lessons" directory dynamically inside "storage/app/public/" Forgot to set permissions for this new directory due to which I was getting 404. Setting the permissions to 755 resolve the issue for me.

2 likes
khwabscript's avatar

In my case i should run the command inside Docker container

docker exec -it containerID bash
> php artisan storage:link

Hope it helps to somebody :)

5 likes
florenxe's avatar

@khwabscript Thanks for this! For the life if me I could not figure out what was going on. This worked perfectly. I'm using heroku to host my app, this looks like one of those commands you only need to run once. Thankfully heroku now has exec (beta) https://devcenter.heroku.com/changelog-items/1112 , it lets you create an SSH-based terminal session into your dyno.

heroku login heroku ps:exec -a your-app-name

Now you can run the artisan command: php artisan storage:link

If you try to hit the public url you might get a permission error, so you need to grant that directory the correct permission. I did a chmod -R 755 storage/app/

MrMoto9000's avatar

@khwabscript Thank you so much. It just needed to be ran within the Docker container, as you said. All good now. Thank you!

Christofer's avatar

Does Windows have symlinks? What's the recommended way to do this on Win11?

Please or to participate in this conversation.