Laravel: RuntimeException: Unsupported cipher or incorrect key length. Supported ciphers are: aes-128-cbc, aes-256-cbc, aes-128-gcm, aes-256-gcm
APP_KEY is missing, malformed or empty, or config/app.php cipher doesn't match the key length.
Unsupported cipher or incorrect key length. Supported ciphers are: aes-128-cbc, aes-256-cbcRuntimeException: Unsupported cipher or incorrect key lengthUnsupported cipher or incorrect key length LaravelNo application encryption key has been specified. Unsupported cipher Meaning
Generate a key with php artisan key:generate (writes base64:... to .env). Check that .env exists on the server, the key line has no spaces/quotes issues, and config isn't cached with an old/empty key. AES-256 needs 32 bytes; a 16-char key with AES-256-CBC fails.
Common causes
- APP_KEY empty (no .env on server)
- Key not base64-prefixed or wrong length
- Config cached before the key existed
.envhasAPP_KEY=with spaces- Cipher changed in config/app.php
⚡ Quick fix
php artisan key:generatephp artisan config:clear- Confirm
.envis present and readable by the web user
Detailed fix by platform
Laravel
php artisan key:generate --force && php artisan config:cache
How to diagnose
- .env — Present?
- Key — base64 32 bytes?
- Cache — Rebuilt?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- 403 This action is unauthorized Laravel: Illuminate\Auth\Access\AuthorizationException: This action is unauthorized.
- Attempt to read property "x" on null Laravel/PHP 8: ErrorException: Attempt to read property "name" on null
- Command "x" is not defined Laravel: Symfony\Component\Console\Exception\CommandNotFoundException: Command "make:livewire" is not defined. Did you mean one of these?
Most viewed in Laravel
- MassAssignmentException Laravel: Illuminate\Database\Eloquent\MassAssignmentException: Add [x] to fillable property to allow mass assignment
- The GET method is not supported for route Laravel: The GET method is not supported for route x. Supported methods: POST (MethodNotAllowedHttpException)
- Route [login] not defined Laravel: Symfony\Component\Routing\Exception\RouteNotFoundException: Route [login] not defined
Other ways to find it
Where this error sits
Origin: Application & API. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 4 Nov 2026