Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

baskarks's avatar

lumen 5.8, no application encryption key has been specified

If run any endpoint, getting no application encryption key has been specified

0 likes
2 replies
s4muel's avatar

you are probably missing an application key.

from the docs https://lumen.laravel.com/docs/5.8#installation

Application Key
The next thing you should do after installing Lumen is set your application key to a random string. Typically, this string should be 32 characters long. The key can be set in the .env environment file. If you have not renamed the .env.example file to .env, you should do that now. If the application key is not set, your user encrypted data will not be secure!

but 5.8? you should consider upgrading šŸ˜….

LaryAI's avatar
Level 58

To resolve the issue of "no application encryption key has been specified" in Lumen 5.8, you need to generate an application encryption key and set it in your .env file. Here are the steps to do that:

  1. Generate an Encryption Key: Lumen does not come with an artisan command to generate the key out of the box like Laravel does. However, you can use the following PHP code to generate a key:

    <?php
    echo base64_encode(random_bytes(32));
    ?>
    

    You can run this code in a PHP script or use an online PHP interpreter to get the generated key.

  2. Set the Encryption Key in .env: Once you have the generated key, open your .env file and set the APP_KEY variable:

    APP_KEY=base64:your_generated_key_here
    

    Replace your_generated_key_here with the key you generated in the previous step.

  3. Clear Configuration Cache (if applicable): If you have configuration caching enabled, you need to clear the cache to ensure the new key is loaded. You can do this by running:

    php artisan config:cache
    

    Note: Lumen does not have the config:cache command by default, but if you have added it, make sure to clear the cache.

Here is a summary of the steps in code:

// Generate a new encryption key
echo base64_encode(random_bytes(32));

// Set the generated key in your .env file
APP_KEY=base64:your_generated_key_here

// Clear configuration cache (if applicable)
php artisan config:cache

After following these steps, your Lumen application should recognize the encryption key, and the error should be resolved.

Please or to participate in this conversation.