Knowledge

No application encryption key has been specified

#Laravel

This Laravel error appears when the APP_KEY is missing. It is one of the first things you hit after cloning a project. The fix is a single artisan command.

Published by Mark van Eijk on June 23, 2026 · 1 minute read

  1. About the error
  2. Why do I see this error
  3. Solution
  4. On a server

About the error

The full message is:

RuntimeException: No application encryption key has been specified.

Laravel uses the APP_KEY to encrypt cookies, sessions and anything you pass through the Crypt facade. Without it, the framework refuses to boot rather than fall back to no encryption.

Why do I see this error

The APP_KEY value in your .env is empty or missing. This almost always happens right after:

  • Cloning a project from Git, the .env is gitignored, so you start without a key.
  • Copying .env.example to .env without generating a fresh key.

Solution

Generate a key. Laravel writes it straight into your .env for you:

php artisan key:generate

If you don't have a .env file yet, create one first:

cp .env.example .env
php artisan key:generate

After generating, your .env will contain a value like:

APP_KEY=base64:Rk9wq3y...=

With debug off, a missing key reaches visitors as a generic 500 Internal Server Error, so this is worth checking first on a fresh deploy.

If you cached your config, clear it so the new key is picked up:

php artisan config:clear

On a server

If you see this in production, the deploy likely doesn't have an APP_KEY set. Generate one once and keep it stable, changing it later invalidates every existing session and encrypted cookie, logging all your users out and making old encrypted data unreadable.

For a non-interactive deploy you can write the key without the confirmation prompt:

php artisan key:generate --force

See environment variables in Laravel for more on how .env values are loaded.

Subscribe to our newsletter

Do you want to receive regular updates with fresh and exclusive content to learn more about web development, hosting, security and performance? Subscribe now!

Related articles

How to use different PHP versions with Laravel Valet

This Laravel error appears when the APP_KEY is missing. It is one of the first things you hit after cloning a project. The fix is a single artisan command.

Read more →

Disable cookies in Laravel

This Laravel error appears when the APP_KEY is missing. It is one of the first things you hit after cloning a project. The fix is a single artisan command.

Read more →