Can you share the stacktrace ? Or even better, share the error page if you can see it
PHP Fatal error: Uncaught RuntimeException: A facade root has not been set.
Hi guys,
I will need your input in some strange error.
After a simple deploy that required a composer install the app just stoped working on the server, but on local is working perfectly.
The error I get says PHP Fatal error: Uncaught RuntimeException: A facade root has not been set. in Illuminate/Support/Facades/Facade.php:335.
I tried all things that I could think of, like:
- to delete vendor, composer.lock and reinstall the project
- clearing config, cache, optimize
- re install of the the entire project
I use Laravel9 & php8.1.
Any idea would be great, because I kind missing any new ideas at this moment.
Thank you in advance.
Hi @sinnbeck , I get the error on each page, the app does not working at all anymore. I get HTTP ERROR 500 on each page.
The stack trace is here:
2023/02/14 09:10:37 [error] 27631#27631: *708 FastCGI sent in stderr: "PHP Fatal error: Uncaught RuntimeException: A facade root has not been set. in /vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:335 Stack trace: #0 /vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/RegisterErrorViewPaths.php(18): Illuminate\Support\Facades\Facade::__callStatic() #1 /vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(642): Illuminate\Foundation\Exceptions\RegisterErrorViewPaths->__invoke() #2 /vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(623): Illuminate\Foundation\Exceptions\Handler->registerErrorViewPaths() #3 /vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(554): Illuminate\Foundation\Exceptions\Handler->renderHttpException() #4 /vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(460): Illuminate\Foundation\Exceptions\Handler->prepareResponse() #5 /vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(377): Illuminate\Foundation\Exceptions\Handler->renderExceptionResponse() /app/Exceptions/Handler.php(48): Illuminate\Foundation\Exceptions\Handler->render() #7 /vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(493): App\Exceptions\Handler->render() #8 /vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(138): Illuminate\Foundation\Http\Kernel->renderException() #9 /public/index.php(55): Illuminate\Foundation\Http\Kernel->handle() #10 {main} thrown in /vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.
@vasi_r Can you enable APP_DEBUG=true in env to get an error page? And can you click share on that and post a link ?
@Sinnbeck it's enabled but i don't have an error page, because on project load I get TTP ERROR 500
@vasi_r Did you run php artisan cache:clear afterwards ?
@vasi_r If you look through the complete stack trace, does it refer to any of your files at all ?
@Sinnbeck yes I run the command and no project related files in stack trace, only vendor files.
@vasi_r Hm ok weird. Did you change anything in index.php to get the project working locally? or is it 100% the version that ships with laravel? Is the project public on github?
@Sinnbeck it's 100% like I have it on local. THe project is in github.
@vasi_r Is it public and can you share a link ?
Also I didnt ask if it was the same as local. I asked if you had changed index.php :)
@Sinnbeck it's not public. And I did not change anything on index.php :)
@vasi_r Ok not sure where the issue then. Maybe check all of your files (like config/app.php or Http/Kernel.php) compared to https://github.com/laravel/laravel
@Sinnbeck I don't know either, that's why I wanted to see a different approach.
The error started after I added blink in the project and run composer install. I tried to remove it, but the error still remained, so I guess is not from that. The file structure is ok, app and Kernel also.
@vasi_r blink ? This ? https://packagist.org/packages/spatie/blink
Does it start working if you uninstall it again ?
@Sinnbeck Laravel blink . No, I tried that first thing. . Sorry for late reply, Laracast is saying that I need to take a breath :)
@vasi_r Yeah it rate limits to avoid spammers :) It gets better the longer you are here.
Just thinking if I can come up with a reason why it would happen. Perhaps checkout an older commit, before it stopped working?
@Sinnbeck I tried that, I had a deprecated branch with different php version and different Laravel version , and I get the same. I really don't understand the issue. I never encounter this type of error. I also suspected the server... but when I added an index.html it renders, so I excluded the server part.
@vasi_r I have seen it before, but it is always due to something like doing queries in a __construct() or similar, and therefor fails on both local and production.. This is new, and I am not really sure what to suggest anymore.
@Sinnbeck exactly... that's a first for me also, to have a error only on the server. The only difference is that on local I use Mac and the server is centos :)... but not have an impact, so I have no other leads to persue at this moment.
@vasi_r Maybe you could try either putting it temporarily on another server (if possible) or set up linux locally in docker to test ?
@Sinnbeck the new server, is not possible at the moment, I will try the docker also... but to be honest I doubt that is the issue.
@vasi_r It is mostly to try and either recreate it locally, or have a production server that works.
@Sinnbeck I just got a simple EC2 server from AWS... and it seems that is working. So the problem must be something with the server. But I have not a clue what and where to start :)
Hi @sinnbeck and all that may encounter this error,
After a long back and forth I found that the issue was from the server. More exactly on the server I had multiple php versions, and for some reason the problem was even I had installed php8.1 it was not set the default version on the server, something did not work't properly. But after I set the default php version on the server to 8.1 the problem just disappeared.
Hope this will help somebody so you don't need go throw all that I went.
Best regards.
@vasi_r i had same or similar issue. same error message, at least. i had upgraded my digital ocean server to everything that was recommended - core packages, php, laravel, whatever else i have no idea. that caused all sorts of problems.
this fix was in my nginx sites-enabled directory for this particular laravel app/server -- i upgraded from php8.0 to php8.2, and these fpm connectors needed to be installed/upgraded, too, and then configured into these config files:
location ~ \.php$ {
#fastcgi_pass unix:/var/run/php/php8.0-fpm.sock; # this is the normal location, change accordingly
fastcgi_pass unix:/var/run/php/php8.2-fpm.sock; # this is the normal location, change accordingly
Had similar issue today. It turned out it was the PHP8.2 version on the server. Took it back to PHP8.1 and it sorted the issue for me. Not sure why it had that issue as I have 8.2 on my docker local setup. Possibly something to do with the php modules or something?
Please or to participate in this conversation.