Skip to content
PHP and Laravel3 min read

"No application encryption key has been specified" in Laravel

No application encryption key has been specified.

Short answer

The error means APP_KEY in your .env file is empty or the file is missing, so Laravel can't encrypt sessions and cookies. Create .env if it doesn't exist, run php artisan key:generate, then php artisan config:clear. Don't generate a new key for a live site with encrypted data without a plan.

ArabyHost teamLast updated: ShareWhatsAppXLinkedIn
Contents
  1. What the error means
  2. Common causes
  3. How to fix it
  4. Think before changing the key on a live site
  5. Prevention
  6. On ArabyHost

Laravel uses APP_KEY to encrypt sessions, cookies and anything you encrypt with Crypt. Without it the app can’t handle its first request, so the error usually appears right after a deploy. With APP_DEBUG=false visitors only see a 500 error, and the full MissingAppKeyException is in storage/logs/laravel.log.

What the error means

On boot, Laravel reads the key from the environment variables in .env. It should look like this:

# example of the format only: never reuse this key
APP_KEY=base64:Xq3m0bYk2rV9tW1hN8pL4cF7sD6gJ5aZ0eR2uI9oP3k=

If it’s empty, the whole file is missing, or an old value is stuck in the config cache, the app stops with this message.

Common causes

  • .env was never uploaded, because it’s deliberately excluded from Git or the upload tool skipped hidden files.
  • .env.example was copied to .env without generating a key, leaving APP_KEY= empty.
  • Configuration is cached in bootstrap/cache/config.php from a time when the key was empty, so Laravel ignores .env.
  • A syntax error in .env, such as an unquoted value with spaces, so the file isn’t read properly.
  • The key was pasted without its base64: prefix.

How to fix it

  1. Show hidden files: in cPanel open Files › File Manager › Settings and enable Show Hidden Files (dotfiles). Check that .env exists in the project folder, next to artisan, not inside public.
  2. Over SSH (AI/Developer plans):
cd ~/myapp
cp -n .env.example .env
php artisan key:generate
php artisan config:clear

-n stops cp from overwriting an existing .env. key:generate writes the new key straight into .env. In production you can then run php artisan config:cache. 3. Without SSH: generate a key on your computer without touching your files:

php artisan key:generate --show

Copy the output starting with base64:, open .env on the server with File Manager’s Edit, paste it on the APP_KEY= line, then delete bootstrap/cache/config.php if it exists. 4. If a different error appears next, such as a permissions error, follow the storage permissions fix.

Think before changing the key on a live site

Generating a new key for an app with users and data has immediate effects: every session ends so everyone must log in again, some may see a 419 error once, and data encrypted with the old key can no longer be read. Since Laravel 11 you can rotate keys safely by keeping the old one in APP_PREVIOUS_KEYS:

APP_KEY=base64:NEW_KEY_HERE
APP_PREVIOUS_KEYS=base64:OLD_KEY_HERE

Prevention

  • Keep a safe copy of the production .env outside Git, for example in a password manager.
  • Never commit APP_KEY to the repository or show it in screenshots.
  • Make public the domain’s web root so .env can’t be downloaded from a browser.

On ArabyHost

Point the domain’s document root to the public folder of your Laravel project, so .env stays outside the web root. On AI/Developer plans you run php artisan key:generate over SSH jailed in CageFS; on other plans you edit .env in File Manager. The Araby AI assistant reads the error log and explains why the app stopped. The full deployment steps are in the Laravel deployment guide.

FAQ

Do user passwords change if I change APP_KEY?

No. Passwords are stored as bcrypt or argon hashes and don't depend on APP_KEY. But current sessions end, and anything encrypted with Crypt or encrypted casts becomes unreadable.

Why can't I see .env in File Manager?

Its name starts with a dot, so it counts as a hidden file. Open Settings in File Manager and enable Show Hidden Files (dotfiles).

Must the key be the same on every server?

Yes. If several servers or processes serve the same app, they must share the same APP_KEY, or decrypting sessions and data between them fails.

Useful? Share it with someone who needs it:WhatsAppXLinkedIn

Read next

Ready to put your idea online?

Fast, isolated hosting, support that understands you, and an AI assistant that fixes problems with you.