Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: No application encryption key has been specified. But it exist

Tags:

php

laravel

I have a Laravel application which is working well, but whenever I view the log file there are hundreds of error

production.ERROR: No application encryption key has been specified. {"exception":"[object] (RuntimeException(code: 0): No application encryption key has been specified.

exist in log file. There is a key in .env file and also I tried php artisan key:generate command as well but the error still generated in log file without any visible error to users.

This error only appears in the production server's log file, not in my development pc.

like image 851
Esmatullah Arifi Avatar asked Jan 02 '23 16:01

Esmatullah Arifi


2 Answers

php artisan key:generate 

This will generate a random key, you must restart the server and you should no longer see the error message.

run the following commands to clear the cache.

php artisan config:clear
php artisan config:cache
like image 98
Udhav Sarvaiya Avatar answered Jan 04 '23 05:01

Udhav Sarvaiya


I'm face to the same issue I have searched a lot but in a YouTube video comment I have found a solution (I'm not sure this solution is good or not) but worked for me
copy APP_KEY from .env file
and past in app.php file (located in: your_project\config)
Your app.php will look like

.
. 
.
‘key’ => env(‘APP_KEY’, ‘base64:insert key here’),
.
. 
.
like image 40
Bilal Khan Avatar answered Jan 04 '23 05:01

Bilal Khan