Laravel says no supported encrypter was found because of the cipher or key length
No supported encrypter found. The cipher and / or key length are invalid.Short answer
Laravel's encrypter needs the application key in APP_KEY, and it cannot start without a usable one. Most of the time the key is empty after a fresh clone or deploy. Check it, generate one with php artisan key:generate, then clear a cached configuration. Also look for a server-level APP_KEY that overrides the .env file.
Fix it fast
1Find out which cause you have
Check that APP_KEY has a value in .env, and that no server environment variable shadows it. The commands print counts, not the key, so you can paste the output safely.
grep -c '^APP_KEY=.\+' .env printenv | grep -c '^APP_KEY='2Match what you see, then jump to its fix
- 1
The first command prints 0, for example after cloning the project and copying .env.example to .envAPP_KEY is empty or missingFix - 2
APP_KEY is in .env now, but the error stays after the change, on a server where config:cache was run during deploymentThe configuration was cached before the key was setFix - 3
The second command in the first step prints 1, and the value comes from the web server, container or process manager, not from .envA server-level APP_KEY overrides the .env valueFix - 4
APP_KEY has a value, no cache or override exists, and the key was typed, trimmed by an editor or pasted from another projectThe key does not fit the cipher: typed by hand, cut short or copied wronglyFix
- 1
What does the error look like?
No supported encrypter found. The cipher and / or key length are invalid.
Cause 1 of 4
APP_KEY is empty or missing
1Check
The Laravel encryption documentation says the key option in config/app.php must be set before the encrypter is used, and that its value is driven by the APP_KEY environment variable.
grep -n '^APP_KEY' .env2Fix
Generate the key with the Artisan command the documentation recommends. It uses PHP's secure random bytes generator and writes APP_KEY into .env.
php artisan key:generate3Verify
Load a page that uses sessions or encrypted cookies; the error is gone.
grep -c '^APP_KEY=.\+' .envConfirmed by laravel.com
Cause 2 of 4
The configuration was cached before the key was set
1Check
The configuration documentation says that after config:cache the .env file is not loaded during requests or Artisan commands, so a key added later is not seen until the cache is rebuilt.
ls bootstrap/cache/config.php2Fix
Clear the cached configuration. When the key is final, cache it again as part of the deployment.
php artisan config:clear
php artisan config:cache3Verify
Request the page again.
curl -I https://example.com/Confirmed by laravel.com
Cause 3 of 4
A server-level APP_KEY overrides the .env value
1Check
The configuration documentation says any variable in .env can be overridden by external environment variables such as server-level or system-level variables. An old or empty APP_KEY there wins.
printenv | grep -c '^APP_KEY='2Fix
Remove the external variable, or set it to the same key that .env holds, in the place where it is defined (the container, service file or hosting panel). Then restart the process.
# remove or correct APP_KEY where the server defines it, then restart PHP and the web server3Verify
Run the same check in the same environment as the web process.
printenv | grep -c '^APP_KEY='Confirmed by laravel.com
Cause 4 of 4
The key does not fit the cipher: typed by hand, cut short or copied wrongly
1Check
The configuration documentation names AES-256-CBC as the default cipher and says it requires a 32 character key. Keys made by key:generate start with base64:, as in the documentation's example, so a value without that prefix was made another way. The command prints 1 when the prefix is there.
grep -c '^APP_KEY="\?base64:' .env2Fix
Generate a new key. Changing the key logs all users out, and data encrypted with the old key can no longer be decrypted. To keep that data readable, the documentation says to list the previous key in APP_PREVIOUS_KEYS.
php artisan key:generate
# .env, only if existing encrypted data must stay readable
APP_PREVIOUS_KEYS="base64:your-old-key-here"3Verify
Clear any cached configuration, then load a page that uses sessions and confirm the error is gone.
php artisan config:clear
curl -I https://example.com/Confirmed by laravel.com
How do I stop it coming back?
- Run php artisan key:generate once as part of project setup, and keep the real key in your secret store, not in git.
- Keep APP_KEY in the same place for every environment: .env, or the platform's secret variables, not both.
- Run config:cache only in the deploy step, after .env or the platform variables are final.
- Never share the key in tickets or screenshots; use counts and lengths when you ask for help.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Back end
Composer says the gd extension is missing on a Laravel project
composer install or composer update stops on a package that requires ext-gd
Composer refuses to install a package that requires ext-gd when the PHP binary running Composer has no GD extension.
4 causes, each with a fixBack end
composer require maatwebsite/excel fails to install
Composer says the package needs an older PHP than the one installed
Composer refuses maatwebsite/excel when the PHP version or a PHP extension does not match what the package and PhpSpreadsheet need.
3 causes, each with a fixBack end
composer install says the lock file is not compatible and asks for update
Your lock file does not contain a compatible set of packages. Please run composer update.
composer install checked the locked packages against this machine's PHP and extensions and found a conflict.
3 causes, each with a fixBack end
composer require laravel/horizon fails: ext-pcntl is missing
laravel/horizon v1.1.0 requires ext-pcntl * -> the requested PHP extension pcntl is missing from your system
Horizon needs the pcntl extension, and Composer refuses to install it where PHP lacks that extension.
3 causes, each with a fixBack end
composer require laravel/passport stops with 'requirements could not be resolved'
... but these were not loaded, likely because it conflicts with another require.
Composer found no Passport release that fits your project at once.
4 causes, each with a fixBack end
Composer says the root composer.json requires a PHP version your PHP does not satisfy
Your requirements could not be resolved to an installable set of packages.
Composer compares the php constraint in your composer.json, or in a package, with the PHP that runs Composer.
3 causes, each with a fix