Unsupported cipher or incorrect key length Laravel Origin: Application & API OSI layer 6 · Presentation Last updated 4 Nov 2026

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.

Exact message you may see 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
Seen on: Laravel PHP

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
  • .env has APP_KEY= with spaces
  • Cipher changed in config/app.php

⚡ Quick fix

  1. php artisan key:generate
  2. php artisan config:clear
  3. Confirm .env is present and readable by the web user

Detailed fix by platform

Laravel

  1. php artisan key:generate --force && php artisan config:cache

How to diagnose

  1. .env — Present?
  2. Key — base64 32 bytes?
  3. 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:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

403 This action is unauthorized — Laravel: Illuminate\Auth\Access\AuthorizationException: This action is unauthorized. (Laravel)403 This action is un…Attempt to read property "x" on null — Laravel/PHP 8: ErrorException: Attempt to read property "name" on null (Laravel)Attempt to read prope…Command "x" is not defined — Laravel: Symfony\Component\Console\Exception\CommandNotFoundException: Command "make:livewire" is not defined. Did you mean one of these? (Laravel)Command "x" is not de…DecryptException: The payload is invalid / The MAC is invalid — Laravel: Illuminate\Contracts\Encryption\DecryptException: The payload is invalid. / The MAC is invalid. (Laravel)DecryptException: The…env() returns null (config cached) — Laravel: .env changes ignored / env('X') returns null after php artisan config:cache (Laravel)env() returns null (c…Laravel: Allowed memory size exhausted (request) — Laravel/PHP: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in vendor/laravel/framework (Laravel)Laravel: Allowed memo…No application encryption key — Laravel: No application encryption key has been specified. (PHP)No application encryp…Unsupport…

Explore the map of this error Full error map →

🧠 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.