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

thebigk's avatar
Level 13

Storage Different Behavior on Local Vs Production Environment

I use Laravel Forge to run my servers. I've observed a weird behavior on my local machine vs forge server.

Local Machine On my local machine (runs Valet) I'm able to access the image on following path:

example.test/articles/images/3f0b45e2-2876-4d09-a671-aef6edea0311.jpg

Production Machine

example.com/articles/images/3f0b45e2-2876-4d09-a671-aef6edea0311.jpg // 404 error
example.com/storage/articles/images/3f0b45e2-2876-4d09-a671-aef6edea0311.jpg // WORKS!

I have created a symlink using php artisan storage:link command on both local and production servers; yet this difference.

Can someone help me understand what's going on with my Forge server? How do I get rid of /storage/ part from the image path and still load images?

0 likes
1 reply
LaryAI's avatar
Level 58

It seems like the issue is with the way the URLs are being generated. On your local machine, the URL is being generated without the "/storage/" prefix, while on the production machine, the URL requires the "/storage/" prefix.

One solution to this problem is to use the Laravel helper function asset() to generate the URLs for your images. This function will automatically add the "/storage/" prefix when running on the production machine, and will generate the URL without the prefix when running on your local machine.

Here's an example of how you can use the asset() function to generate the URL for your image:

<img src="{{ asset('articles/images/3f0b45e2-2876-4d09-a671-aef6edea0311.jpg') }}" alt="Article Image">

This code will generate the correct URL for your image, regardless of whether you're running on your local machine or on the production machine.

If you're still having issues, you may want to check your server configuration to ensure that the symlink was created correctly. You can also try running the php artisan storage:link command again to recreate the symlink.

Please or to participate in this conversation.