did you clear config cache? php artisan config:clear
Login and logout : No application encryption key has been specified
Hello every one, I will became crazy. When I try to login or logout, I have the 'No application encryption key has been specified' error.
When I look in my .env, my APP_KEY is fill.
In my app.php
'key' => env('APP_KEY')
It's like it can't load my .env. This is my $config in the EncryptionServiceProvider.php
array:26 [▼ // vendor\laravel\framework\src\Illuminate\Encryption\EncryptionServiceProvider.php:80
"name" => "Hotel2for1"
"env" => "production"
"debug" => false
"url" => "http://localhost"
"frontend_url" => "http://localhost:3000"
"asset_url" => null
"timezone" => "Europe/Paris"
"locale" => "fr"
"fallback_locale" => "fr"
"faker_locale" => "fr_FR"
"cipher" => "AES-256-CBC"
"key" => null
"previous_keys" => []
"maintenance" => array:2 [▶]
"providers" => array:29 [▶]
"aliases" => array:62 [▶]
"faker_date_format" => "Y-m-d 00:00:00"
"user_date_format" => "d/m/Y"
"db_date_format" => "Y-m-d"
"secret_stripe" => null
"public_stripe" => null
"admin_email" => null
"insurance" => 3.5
"opinion_max" => 10
]
As you see, all the value are by default. Secret_stripe, public_stripe and admin_email are also null but fill well in my env file.
The probleme seems to come line 47 when it try to load the config with $this->app->make('config')->get('app'):
protected function registerSerializableClosureSecurityKey()
{
$config = $this->app->make('config')->get('app');
if (! class_exists(SerializableClosure::class) || empty($config['key'])) {
return;
}
SerializableClosure::setSecretKey($this->parseKey($config));
}
I don't know what to do ...
ps: php artisan config:clear and php artisan key:generate made several time
ps2: It's on anexiting project, I update it on Laravel 11 but no change.
Hello, thank's for the answer.
Yes i did several time php artisan config:clear and php artisan key:generate
stack trace?
There it is, sorry
[2024-04-30 09:56:47] production.ERROR: No application encryption key has been specified. {"exception":"[object] (Illuminate\Encryption\MissingAppKeyException(code: 0): No application encryption key has been specified. at D:\h2f1\vendor\laravel\framework\src\Illuminate\Encryption\EncryptionServiceProvider.php:83)
[stacktrace]
#0 D:\h2f1\vendor\laravel\framework\src\Illuminate\Support\helpers.php(359): Illuminate\Encryption\EncryptionServiceProvider->Illuminate\Encryption\{closure}(NULL)
#1 D:\h2f1\vendor\laravel\framework\src\Illuminate\Encryption\EncryptionServiceProvider.php(81): tap(NULL, Object(Closure))
#2 D:\h2f1\vendor\laravel\framework\src\Illuminate\Encryption\EncryptionServiceProvider.php(64): Illuminate\Encryption\EncryptionServiceProvider->key(Array)
#3 D:\h2f1\vendor\laravel\framework\src\Illuminate\Encryption\EncryptionServiceProvider.php(32): Illuminate\Encryption\EncryptionServiceProvider->parseKey(Array)
#4 D:\h2f1\vendor\laravel\framework\src\Illuminate\Container\Container.php(900): Illuminate\Encryption\EncryptionServiceProvider->Illuminate\Encryption\{closure}(Object(Illuminate\Foundation\Application), Array)
#5 D:\h2f1\vendor\laravel\framework\src\Illuminate\Container\Container.php(787): Illuminate\Container\Container->build(Object(Closure))
#6 D:\h2f1\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(1026): Illuminate\Container\Container->resolve('encrypter', Array, true)
#7 D:\h2f1\vendor\laravel\framework\src\Illuminate\Container\Container.php(723): Illuminate\Foundation\Application->resolve('encrypter', Array)
#8 D:\h2f1\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(1011): Illuminate\Container\Container->make('encrypter', Array)
#9 D:\h2f1\vendor\laravel\framework\src\Illuminate\Container\Container.php(1058): Illuminate\Foundation\Application->make('encrypter')
#10 D:\h2f1\vendor\laravel\framework\src\Illuminate\Container\Container.php(974): Illuminate\Container\Container->resolveClass(Object(ReflectionParameter))
#11 D:\h2f1\vendor\laravel\framework\src\Illuminate\Container\Container.php(935): Illuminate\Container\Container->resolveDependencies(Array)
#12 D:\h2f1\vendor\laravel\framework\src\Illuminate\Container\Container.php(787): Illuminate\Container\Container->build('App\\Http\\Middle...')
#13 D:\h2f1\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(1026): Illuminate\Container\Container->resolve('App\\Http\\Middle...', Array, true)
#14 D:\h2f1\vendor\laravel\framework\src\Illuminate\Container\Container.php(723): Illuminate\Foundation\Application->resolve('App\\Http\\Middle...', Array)
#15 D:\h2f1\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(1011): Illuminate\Container\Container->make('App\\Http\\Middle...', Array)
#16 D:\h2f1\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(172): Illuminate\Foundation\Application->make('App\\Http\\Middle...')
#17 D:\h2f1\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(119): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#18 D:\h2f1\vendor\laravel\framework\src\Illuminate\Routing\Router.php(805): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#19 D:\h2f1\vendor\laravel\framework\src\Illuminate\Routing\Router.php(784): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#20 D:\h2f1\vendor\laravel\framework\src\Illuminate\Routing\Router.php(748): Illuminate\Routing\Router->runRoute(Object(Illuminate\Http\Request), Object(Illuminate\Routing\Route))
#21 D:\h2f1\vendor\laravel\framework\src\Illuminate\Routing\Router.php(737): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#22 D:\h2f1\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(200): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#23 D:\h2f1\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(144): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request))
#24 D:\h2f1\vendor\livewire\livewire\src\Features\SupportDisablingBackButtonCache\DisableBackButtonCacheMiddleware.php(19): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#25 D:\h2f1\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(183): Livewire\Features\SupportDisablingBackButtonCache\DisableBackButtonCacheMiddleware->handle(Object(Illuminate\Http\Request), Object(Closure))
#26 D:\h2f1\vendor\barryvdh\laravel-debugbar\src\Middleware\InjectDebugbar.php(59): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#27 D:\h2f1\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(183): Barryvdh\Debugbar\Middleware\InjectDebugbar->handle(Object(Illuminate\Http\Request), Object(Closure))
#28 D:\h2f1\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#29 D:\h2f1\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull.php(31): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))
#30 D:\h2f1\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(183): Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull->handle(Object(Illuminate\Http\Request), Object(Closure))
#31 D:\h2f1\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#32 D:\h2f1\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\TrimStrings.php(51): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))
#33 D:\h2f1\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(183): Illuminate\Foundation\Http\Middleware\TrimStrings->handle(Object(Illuminate\Http\Request), Object(Closure))
#34 D:\h2f1\vendor\laravel\framework\src\Illuminate\Http\Middleware\ValidatePostSize.php(27): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#35 D:\h2f1\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(183): Illuminate\Http\Middleware\ValidatePostSize->handle(Object(Illuminate\Http\Request), Object(Closure))
#36 D:\h2f1\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance.php(110): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#37 D:\h2f1\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(183): Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance->handle(Object(Illuminate\Http\Request), Object(Closure))
#38 D:\h2f1\vendor\laravel\framework\src\Illuminate\Http\Middleware\HandleCors.php(49): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#39 D:\h2f1\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(183): Illuminate\Http\Middleware\HandleCors->handle(Object(Illuminate\Http\Request), Object(Closure))
#40 D:\h2f1\vendor\laravel\framework\src\Illuminate\Http\Middleware\TrustProxies.php(57): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#41 D:\h2f1\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(183): Illuminate\Http\Middleware\TrustProxies->handle(Object(Illuminate\Http\Request), Object(Closure))
#42 D:\h2f1\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(119): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#43 D:\h2f1\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(175): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#44 D:\h2f1\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(144): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#45 D:\h2f1\public\index.php(51): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#46 {main}
"}
Is this a new application or an existing application where this issue suddenly started ?
@gych It's an existing application and this issue appear suddenly, it was couple month ago, i update in Laravel 11 but still there
what folder is your .env in?
@Snapey In the main folder of my project, like laravel ask. The problem appears only when i login and logout, other time my env is well loaded (ex: database connection is good)
@methos check that you
- dont have the key mentioned twice in .env
- that you don't have a real environment variable
- and if you open tinker and run
config('app')that you see the key you expect
@Snapey thx for your answer and sorry to be late:
- dont have the key mentioned twice in .env : no twice key, and overwise, over values will be loaded aswell
- that you don't have a real environment variable: I don't understand what you mean.
- tinker: my key and env is correct
Thx a lot for your time
@snapey No more idea ? The problem does not occure in production mode, but in local, dev and test.
It's quite boring !
Thx in advance !
Little up ! Anyone have an idea ?
Please try once with generate new Key
php artisan key:generate
@Himmat I already did it couple of time :'( I did it again for you but nothing change...
I still have my problem, no one have an idea ? This appens in all my projects at differents moments ...
Hello, i am getting the same error, but not on login / logout, but on a form validation that is made with multiple steps validation. I am using InertiaJS with vue and i get the exact same error as this guy, same stacktrace as him. It is weird because before i get this error, the validation is not working at all.
I have a form that has 11 steps. And i validate each step, and the first step, on a random occasion it does not get validate and the user can get to the second step withouth the first step getting validated.
But the thing is, this error gets randomly - i refresh the page and validate the form 2-3-4-5 times and it works, and then it doens't or i get this error. It's kinda weird, need to look more into it.
Stacktrace
[2024-08-18 21:11:23] production.ERROR: No application encryption key has been specified. {"exception":"[object] (Illuminate\Encryption\MissingAppKeyException(code: 0): No application encryption key has been specified. at D:\xampp\htdocs\project\vendor\laravel\framework\src\Illuminate\Encryption\EncryptionServiceProvider.php:83)
[stacktrace]
#0 D:\xampp\htdocs\project\vendor\laravel\framework\src\Illuminate\Support\helpers.php(380): Illuminate\Encryption\EncryptionServiceProvider->Illuminate\Encryption\{closure}(NULL)
#1 D:\xampp\htdocs\project\vendor\laravel\framework\src\Illuminate\Encryption\EncryptionServiceProvider.php(81): tap(NULL, Object(Closure))
#2 D:\xampp\htdocs\project\vendor\laravel\framework\src\Illuminate\Encryption\EncryptionServiceProvider.php(64): Illuminate\Encryption\EncryptionServiceProvider->key(Array)
#3 D:\xampp\htdocs\project\vendor\laravel\framework\src\Illuminate\Encryption\EncryptionServiceProvider.php(32): Illuminate\Encryption\EncryptionServiceProvider->parseKey(Array)
#4 D:\xampp\htdocs\project\vendor\laravel\framework\src\Illuminate\Container\Container.php(931): Illuminate\Encryption\EncryptionServiceProvider->Illuminate\Encryption\{closure}(Object(Illuminate\Foundation\Application), Array)
#5 D:\xampp\htdocs\project\vendor\laravel\framework\src\Illuminate\Container\Container.php(815): Illuminate\Container\Container->build(Object(Closure))
#6 D:\xampp\htdocs\project\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(1046): Illuminate\Container\Container->resolve('encrypter', Array, true)
#7 D:\xampp\htdocs\project\vendor\laravel\framework\src\Illuminate\Container\Container.php(751): Illuminate\Foundation\Application->resolve('encrypter', Array)
#8 D:\xampp\htdocs\project\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(1028): Illuminate\Container\Container->make('encrypter', Array)
#9 D:\xampp\htdocs\project\vendor\laravel\framework\src\Illuminate\Container\Container.php(1119): Illuminate\Foundation\Application->make('encrypter')
#10 D:\xampp\htdocs\project\vendor\laravel\framework\src\Illuminate\Container\Container.php(1022): Illuminate\Container\Container->resolveClass(Object(ReflectionParameter))
#11 D:\xampp\htdocs\project\vendor\laravel\framework\src\Illuminate\Container\Container.php(973): Illuminate\Container\Container->resolveDependencies(Array)
#12 D:\xampp\htdocs\project\vendor\laravel\framework\src\Illuminate\Container\Container.php(815): Illuminate\Container\Container->build('App\\Http\\Middle...')
#13 D:\xampp\htdocs\project\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(1046): Illuminate\Container\Container->resolve('App\\Http\\Middle...', Array, true)
#14 D:\xampp\htdocs\project\vendor\laravel\framework\src\Illuminate\Container\Container.php(751): Illuminate\Foundation\Application->resolve('App\\Http\\Middle...', Array)
#15 D:\xampp\htdocs\project\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(1028): Illuminate\Container\Container->make('App\\Http\\Middle...', Array)
#16 D:\xampp\htdocs\project\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(172): Illuminate\Foundation\Application->make('App\\Http\\Middle...')
#17 D:\xampp\htdocs\project\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(119): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#18 D:\xampp\htdocs\project\vendor\laravel\framework\src\Illuminate\Routing\Router.php(807): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#19 D:\xampp\htdocs\project\vendor\laravel\framework\src\Illuminate\Routing\Router.php(786): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#20 D:\xampp\htdocs\project\vendor\laravel\framework\src\Illuminate\Routing\Router.php(750): Illuminate\Routing\Router->runRoute(Object(Illuminate\Http\Request), Object(Illuminate\Routing\Route))
#21 D:\xampp\htdocs\project\vendor\laravel\framework\src\Illuminate\Routing\Router.php(739): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#22 D:\xampp\htdocs\project\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(201): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#23 D:\xampp\htdocs\project\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(144): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request))
#24 D:\xampp\htdocs\project\vendor\barryvdh\laravel-debugbar\src\Middleware\InjectDebugbar.php(59): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#25 D:\xampp\htdocs\project\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(183): Barryvdh\Debugbar\Middleware\InjectDebugbar->handle(Object(Illuminate\Http\Request), Object(Closure))
#26 D:\xampp\htdocs\project\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#27 D:\xampp\htdocs\project\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull.php(31): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))
#28 D:\xampp\htdocs\project\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(183): Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull->handle(Object(Illuminate\Http\Request), Object(Closure))
#29 D:\xampp\htdocs\project\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#30 D:\xampp\htdocs\project\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\TrimStrings.php(51): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))
#31 D:\xampp\htdocs\project\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(183): Illuminate\Foundation\Http\Middleware\TrimStrings->handle(Object(Illuminate\Http\Request), Object(Closure))
#32 D:\xampp\htdocs\project\vendor\laravel\framework\src\Illuminate\Http\Middleware\ValidatePostSize.php(27): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#33 D:\xampp\htdocs\project\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(183): Illuminate\Http\Middleware\ValidatePostSize->handle(Object(Illuminate\Http\Request), Object(Closure))
#34 D:\xampp\htdocs\project\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance.php(110): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#35 D:\xampp\htdocs\project\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(183): Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance->handle(Object(Illuminate\Http\Request), Object(Closure))
#36 D:\xampp\htdocs\project\vendor\laravel\framework\src\Illuminate\Http\Middleware\HandleCors.php(49): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#37 D:\xampp\htdocs\project\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(183): Illuminate\Http\Middleware\HandleCors->handle(Object(Illuminate\Http\Request), Object(Closure))
#38 D:\xampp\htdocs\project\vendor\laravel\framework\src\Illuminate\Http\Middleware\TrustProxies.php(57): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#39 D:\xampp\htdocs\project\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(183): Illuminate\Http\Middleware\TrustProxies->handle(Object(Illuminate\Http\Request), Object(Closure))
#40 D:\xampp\htdocs\project\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(119): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#41 D:\xampp\htdocs\project\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(176): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#42 D:\xampp\htdocs\project\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(145): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#43 D:\xampp\htdocs\project\public\index.php(51): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#44 {main}
"}
I have the same issue.
Looks like Debugbar caused this problem. I don’t have the answer why, but disabling debugbar helped.
… I think now I need new debug tool for debugging debugbar )
Please or to participate in this conversation.