Laravel No application encryption key has been specified

Laravel No application encryption key has been specified

  • 14 July, 2018
  • Renish Khunt
  • Laravel

Many times when we create new Laravel setup or clone existing Laravel Repository we get an error message like “No application encryption key has been specified” that means the encryption key has not been specifying on Laravel configuration file. When I get this error at that time I have many questions on my mind like

  1. What is the encryption key?
  2. Why do we need to specify encryption key?
  3.  Where can I update the encryption key?

What is the encryption key?

Laravel encryption key is secure and 50 character key generated by Laravel. The encryption key is used to make your Laravel application secure.

Why do we need to specify encryption key?

We must specify the encryption key for Laravel application because the encryption key is using for making your application secure.

Where can I update the encryption key?

We can specify Laravel encryption key on the “config/app.php” file.

Let’s see how we can set the encryption key for Laravel Application We can create Laravel encryption key using two ways.

The first way we can manually write encryption key on “config/app.php” file like

'key' => 'base64:aB+BccY83Jq7q9eALCrsITQp4pxo5pnT5H/+z9KK7ek=',

The Second way we can generate random and unique encryption key using artisan command like

php artisan key:generate

I suggest the second way for creating the encryption key because if the encryption key is not set properly then all values encrypted by Laravel Insecure. You can find more detail about Laravel encryption here.

Write the comment below if you have any question about Laravel encryption.