No Application Encryption Key Has Been Specified

485,177

Solution 1

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.

Solution 2

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

php artisan key:generate
php artisan config:cache

Solution 3

Open command prompt in the root folder of your project and run below command:

php artisan key:generate

It will generate Application Key for your application.

You can find the generated application key(APP_KEY) in .env file.

Solution 4

  1. Copy .env.example to .env:

    cp -a .env.example .env

  2. Generate a key:

    php artisan key:generate

  3. Only then run:

    php artisan serve

Solution 5

Simply run this command:

php artisan key:generate
Share:
485,177
Carlos F
Author by

Carlos F

Updated on July 08, 2022

Comments

  • Carlos F
    Carlos F almost 2 years

    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.