Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No Application Encryption Key Has Been Specified

I'm new to Laravel and I'm trying to use the Artisan command...

php artisan serve 

It displays...

Laravel development server started: http://127.0.0.1:8000

However, it won't automatically launch and when I manually enter http://127.0.0.1:8000 it shows this error:

RuntimeException No application encryption key has been specified.

Any ideas? I'm using Laravel framework 5.5-dev.

like image 717
Carlos F Avatar asked Jun 30 '17 06:06

Carlos F


People also ask

How do you fix no application encryption key has been specified?

To solve this issue you will have to generate a APP_KEY which is located within your . env (environment) file. To generate the key you can run the Laravel Artisan key generate command. Once you have generated it you can try again and refresh your Laravel application in the browser to see if the page is running or not.

What is PHP artisan serve?

The Laravel PHP artisan serve command helps running applications on the PHP development server. As a developer, you can use Laravel artisan serve to develop and test various functions within the application. It also accepts two additional options. You can use the host for changing application's address and port.

What does PHP artisan config cache do?

php artisan config:cache This command clears the cached config file as mentioned above and recaches the latest configurations into a single file again.


2 Answers

From Encryption - Laravel - The PHP Framework For Web Artisans:

"Before using Laravel's encrypter, you must set a key option in your config/app.php configuration file. You should use the php artisan key:generate command to generate this key"

I found that using this complex internet query in google.com:

"laravel add encrption key" (Yes, it worked even with the typo!)

Note that if the .env file contains the key but you are still getting an application key error, then run php artisan config:cache to clear and reset the config.

like image 73
Amarnasan Avatar answered Oct 08 '22 02:10

Amarnasan


In my case, I also needed to reset the cached config files:

php artisan key:generate php artisan config:cache 
like image 20
Leonid Dashko Avatar answered Oct 08 '22 04:10

Leonid Dashko