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

hoverbover's avatar

Deploy to server - invalid cipher / key length

I'm trying to get my project to show on a server. I was trying to follow this guide which seems well known: https://medium.com/laravel-news/the-simple-guide-to-deploy-laravel-5-application-on-shared-hosting-1a8d0aee923e#.gity4dl56

When I go to the site , it says: RuntimeException in EncryptionServiceProvider.php line 45: No supported encrypter found. The cipher and / or key length are invalid.

I was wondering if I could get some advice on what things to check?

On this server, the files are supposed to be uploaded to a "htdocs" folder, so that's were I put it.

Since the contents of the "public" folder is moved to the root folder (as the guide suggests), I adjusted the paths in the index.php file to:

  require __DIR__.'/bootstrap/autoload.php';     

 $app = require_once __DIR__.'/bootstrap/app.php';

And the bootstrap/app.php has this line:

$app = new Illuminate\Foundation\Application(
    realpath(__DIR__.'/../')

The "storage" folder has these permissions: rwxr-xr-x.

In the .env file , it says APP_ENV=local , is that correct?

It has an APP_KEY with 32 characters

I set the DB_HOST to localhost, and I have added the database name , username and password.

In config/app.php, the cipher is set as: 'cipher' => 'AES-256-CBC',

How could I troubleshoot this?

0 likes
1 reply
hoverbover's avatar
hoverbover
OP
Best Answer
Level 1

It seems that for some reason the .env file wasn't read.

When I set the app key directly in the config/app.php file, it worked:

   'key' => env('APP_KEY', 'iOnIPfvBhsuFCZxEMIoYqw199R7qHVUI'),

So now it works, but if anyone have any idea on what should be done to make the .env file work, that would be interseting.

Please or to participate in this conversation.