Laravel 7 Fatal error: Uncaught RuntimeException: A facade root has not been set
Asked Answered
L

5

6

I have looked at several answers suggested to a similar issue but nothing worked in my case. FYI, this is my first project in Laravel 7, working fine on my Mac. I have deployed the project on my server following this article. When running the project on the web, I get the following error :

Fatal error: Uncaught RuntimeException: A facade root has not been set. in /usr/www/users/utopiqwvpw/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:258

Stack trace: #0 /usr/www/users/utopiqwvpw/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(425): Illuminate\Support\Facades\Facade::__callStatic('replaceNamespac...', Array) #1 /usr/www/users/utopiqwvpw/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(402): Illuminate\Foundation\Exceptions\Handler->registerErrorViewPaths() #2 /usr/www/users/utopiqwvpw/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(313): Illuminate\Foundation\Exceptions\Handler->renderHttpException(Object(Symfony\Component\HttpKernel\Exception\HttpException)) #3 /usr/www/users/utopiqwvpw/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(210): Illuminate\Foundation\Exceptions\Handler->prepareResponse(Object(Illuminate\Http\Request), Object(Symfony\Component\HttpKernel\Exception\HttpExcepti in /usr/www/users/utopiqwvpw/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php on line 258

How can I fix it?

Levon answered 7/5, 2020 at 6:47 Comment(2)
It might be a permission error, I don't know maybe SELinux error, did you try to disable it temporary like > setenforce 0 if you are using centos you can search for the cmd if you are using other OSBrandon
run the php artisan optimize in consoleGemoets
L
8

I finally found a solution that worked in my case.

  1. delete the folder vendor
  2. run composer update
  3. run php artisan config:cache
  4. run php artisan config:clear

Home page now displays but the routes do not work...

Levon answered 7/5, 2020 at 7:47 Comment(0)
P
1

If the solution from @Paul Godard doesn't work, it could be a psr/log issue as mine.

My composer update added psr/log v2.0.0, which requires php8. However, my application is on php7.4

That gave me the exact error output like in the description

Fatal error: Uncaught RuntimeException: A facade root has not been set. in /usr/www/users/utopiqwvpw/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:258

My solution was to specify in composer.json that I'm using "psr/log": "^1.1.0"

Then run composer update

Prestonprestress answered 1/11, 2021 at 18:33 Comment(0)
C
1

This also happens when laravel has some errors at php level, like in the case of undefined constants in configuration files until the application even gets bootstrapped. In my case, I had "Undefined constant Redis::SERIALIZER_IGBINARY" in config/database.php. To solve that we have to install php redis module along with igbinary serializer for example.

Challah answered 2/9, 2023 at 17:5 Comment(0)
C
0

I got that error when my config folder was deleted by mistake. So after recovering the config folder. My project worked fine. You have to check if any folder is removed on which project is depending. Recover or copy it. It will work fine then.

Confiteor answered 11/2, 2023 at 21:22 Comment(0)
F
-2

I tried all the way from all forum but none of them work, finally I resolve the issue.

Just rename your config folder as config_backup and just copy the config from a fresh Laravel project and paste it in your project folder then it will resolve.

Fogle answered 9/5, 2023 at 18:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.