Note: This question is not a duplicate of these questions:
I'm getting this error:
production.ERROR: exception 'RuntimeException' with message 'No supported encrypter found. The cipher and / or key length are invalid.' in /home/coder/.local/share/Trash/files/myblog/vendor/laravel/framework/src/Illuminate/Encryption/EncryptionServiceProvider.php:45
When I tried dd($config['key']);
it returns 'null'. Even the database environment variables return null. So it means that Laravel is not reading from the .env file.
- What is the reason?
- How to fix this?
right now I've solved the issue by manually specifying key in Config/app.php file and setting the database values in Config/database.php file
I suspect that I've got the permissions/owner wrong on the .env file. I'm developing in Elementary OS
I experienced this. And as a result of some hint given by @Spholt above, the reason was that apache(user www-data) could not read .env due to file permissions. So i changed the file permissions to ensure that the server (apache) had read permissions to the file. Just that and boom, it was all working now!
To be sure that the latest version of you
.env
file is being read make sure you runphp artisan config:clear
.You may also want to run
php artisan key:generate
to generate a key for your app (if you haven't already done so). It wouldn't hurt to check the your cipher isAES-256-CBC
or better inconfig/app.php
at the same time.If this is a local dev environment and you think permissions to the
.env
file might be wrong, check them like so:Note
Also be aware that depending on your development environment, some
$_ENV
variables can be set in places likehomestead.yaml
ornginx.conf
.