• Register
0 votes

Problem :

I have recently installed a new fresh copy of laravel 5.3 using composer but I keep getting following error:

The only supported ciphers are AES-128-CBC and AES-256-CBC with the correct key lengths. Even though my app.php file in config directory specify
'cipher' => 'AES-128-CBC',

7.5k points

Please log in or register to answer this question.

2 Answers

0 votes

Solution :

I have lots of industry experience in writing complex code.I have gone through your post and understood your problem.Please follow below approach to resolve your issue:.

To begin with you must ensure first that you have a valid .env file which you can use in the terminal by copying the existing .env.example file as following:

$ cp .env.example .env

After that you need to generate your application Key by using following command:

$ php artisan key:generate

Once this is achieved please make sure that you open your .env file and also ensure that the APP_KEY looks correct as follows:


If  observed carefully you will notice that the key length is wrong for some unknown reason maybe because of running key : generate multiple times it has two base64= keys present there. So just Removing one is the fix to your problems. I was also having and this appears to be an Artisan/Laravel bug.

Hope this answer helps you or who may be struggling with the similar problems or annoying bug

38.6k points
0 votes


You require to have .env on your appication folder then run:

$ php artisan key:generate

In case you don't have .env copy from .env.example:

$ cp .env.example .env

Run php artisan key:generate.

Do php artisan config:clear,

Thereafter php artisan config:cache

And things will begin performing

Run this commands on your terminal:

php artisan config:clear
php artisan config:cache

In case you are running a Laravel project for the first time in that machine ensure that you have the required requirements. Open your CMD/Terminal in your project directory or

cd to/your/project/dir

Provide this command again:

composer update

Alter your .env.example to .env and make required changes in that file particularly database configurations to avoid db error. Then

php artisan key:generate

This resolves this AES cipher key length issue each time I make a Laravel project or clone it from git.

Follow These Steps:

Step 1: Ensure that you have .env file in your application. In case not run this command cp .env.example .env

Step 2: Now run following command ( php artisan key:generate ) to produced a key and it will obtain saved in .env file automatically.

Step 3: Run php artisan config:cache in case you want to cache the configurtration Or php artisan config:clear

run this command

php artisan key:generate

and the clear config cache using

php artisan config:cache


31.7k points
edited by