DEV Community

Ankit Verma
Ankit Verma

Posted on

2

Link to storage folder not working on shared hosting (Hostinger, cPanel, hPanel Fix)

If you're hosting your Laravel project on shared hosting like Hostinger, using cPanel or hPanel, you may run into an issue where the public/storage link doesn't work as expected.

This typically happens because symlinks are restricted or not supported on many shared hosting environments. As a result, running php artisan storage:link either fails silently or has no effect — leaving your uploaded files inaccessible via the browser.

But don't worry — here's a simple workaround that doesn't require symlinks or SSH access.

Laravel normally creates a symbolic link to expose those files to the public:

public/storage → storage/app/public
Enter fullscreen mode Exit fullscreen mode

The Solution: Change Filesystem Path

To make it work without symlinks, just tell Laravel to use public/storage as the root of your public disk.

Step-by-step:

  1. Open the config/filesystems.php file in your Laravel project.
  2. Find this part:
'public' => [
    'driver' => 'local',
    'root' => storage_path('app/public'),
    'url' => env('APP_URL').'/storage',
    'visibility' => 'public',
    'throw' => false,
    'report' => false,
],
Enter fullscreen mode Exit fullscreen mode
  1. Change this line:
'root' => storage_path('app/public'),
Enter fullscreen mode Exit fullscreen mode

to:

'root' => public_path('storage'),
Enter fullscreen mode Exit fullscreen mode

Full updated config:

'public' => [
    'driver' => 'local',
    'root' => public_path('storage'),
    'url' => env('APP_URL').'/storage',
    'visibility' => 'public',
    'throw' => false,
    'report' => false,
],
Enter fullscreen mode Exit fullscreen mode

Now Laravel will save and load files directly from the public/storage folder — no symlink required!

Just make sure the public/storage folder exists and is writable:

mkdir -p public/storage
chmod -R 755 public/storage
Enter fullscreen mode Exit fullscreen mode

Top comments (0)