3

I am running php artisan cache:clear to clear the cache in Godaddy shared hosting through SSH.

My other artisan commands working but php artisan cache:clear not.

I am getting following error :

Failed to clear cache. Make sure you have the appropriate permissions.
Dhairya Lakhera
  • 4,445
  • 3
  • 35
  • 62
  • make sure `bootstrap/cache` folder have correct permission `read/write` – Kamlesh Paul Sep 28 '20 at 10:26
  • Make sure that your user has correct permissions on `storage/cache` folder. If not take a look on this question and give correct permissions. https://stackoverflow.com/questions/30639174/how-to-set-up-file-permissions-for-laravel – Malkhazi Dartsmelidze Sep 28 '20 at 10:27

3 Answers3

4

I fixed this issue by deleting all files in bootstrap/cache. Then, run the following commands.

php artisan cache:clear

composer dump-autoload
Karl Hill
  • 12,937
  • 5
  • 58
  • 95
Razor Mureithi
  • 351
  • 1
  • 4
  • 15
1

The user that executes php artisan cache:clear must have write permissions on the following directories and content recursively.

booststrap/cache/*
storage/*

To check files that user does not have write permission for

find booststrap/cache storage -not -perm -u=w

Finally fix permissions:

chmod -R u+w bootstrap/cache storage
8ctopus
  • 2,617
  • 2
  • 18
  • 25
  • thank you! not having permission on ALL directories in those folders was what was causing the problems for me, even if the problematic folder was not directly related to cache – Marko D Apr 10 '23 at 17:53
0

You can also user Artisan facade to clear cache in live server/production.

Artisan::call('cache:clear');
Niklesh Raut
  • 34,013
  • 16
  • 75
  • 109