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

RafaelMunoznl's avatar

500 Error: Cannot serve directory - No matching DirectoryIndex found

I have deploy an app fully working in Localhost but in the production server, every time I log in I get a 500 error.

After I refresh the page, the user is logged in.

I could visit all pages, but I can not upload images (change from avatar to the uploaded image). I get the 500 error again.

Looking at the logs I get this:

[Fri Feb 21 11:00:10.620900 2020] [autoindex:error] [pid 1579]
[client 46.189.69.156:51442] AH01276: Cannot serve directory /home/363286.cloudwaysapps.com/bkbqeheexz/public_html/public/storage/: No matching DirectoryIndex (index.php,default.php,index.html,default.html) found, and server-generated directory index forbidden by Options directive, referer: http://phplaravel-363286-1171349.cloudwaysapps.com/admin/dashboard 

I followed all needed steps in the deployment: https://support.cloudways.com/deploy-laravel-on-cloudways/?utm_source=Platformkb&utm_medium=kbsearch


I also did this:

  • I generated the necessary key: php artisan key:generate
  • php artisan clear-compiled
  • php artisan cache:clear
  • php artisan route:clear
  • php artisan view:clear
  • php artisan config:clear
  • composer dumpautoload -o
  • php artisan storage:link

But now I am still having the 500 Error every time I visit a page with images (user images)

It seems to be a problem with the storage linking, but I have not idea, what to do.

Any help would be appreciated

0 likes
3 replies
Sinnbeck's avatar

It seems that your code is calling the storage directory directly? LIke it should call a file but the filename is missing

 Cannot serve directory /home/363286.cloudwaysapps.com/bkbqeheexz/public_html/public/storage/
RafaelMunoznl's avatar

@sinnbeck I have used the Laravel boilerplate. But it is giving me more troubles than I expected. The documentation does not mention any solution about this

RafaelMunoznl's avatar

@sinnbeck

After accessing to the laravel.log file I found this:

[2020-02-21 15:48:39] local.ERROR: SQLSTATE[HY000]: 

General error: 1364 Field 'id' doesn't have a default value

 (SQL: insert into `ledgers` (`user_id`, `user_type`, `context`, `event`, `recordable_id`, `recordable_type`, `properties`, `modified`, `extra`, `url`, `ip_address`, `user_agent`, `created_at`, `updated_at`,
`pivot`, `signature`) 

values 

(4, App\Models\Auth\User, 4, updated, 4, App\Models\Auth\User, {"id":4,"uuid":"83e5a26f-813c-4933-95df-112e7bd95f48","first_name"
:"Marianne","last_name":"smith","email":"[email protected]","avatar_type":"storage","avatar_location":"avatars\/... and so on.

As far as I see, the SQL query is not sending the id Field that the database expects.

The Laravel boilerplate uses ledger package in order to track all users related events (logged in, logged out, confirmed and so on).

That's why I get the error every time users upload an image, or log in or log out.

I think at the moment the only solution is get rid of the package

Please or to participate in this conversation.