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

skoobi's avatar
Level 13

No application encryption key has been specified.

Hi. Im hitting the same issue as before but this time i cannot get i back working.

Nothing has changed other than a few controller files and view files, but when i push to the server it fails and says

> @php artisan package:discover

In EncryptionServiceProvider.php line 42:
                                                     
  No application encryption key has been specified.  
                                                     

Script @php artisan package:discover handling the post-autoload-dump event returned with error code 1

Now there is a key generated and it has been working perfect for the last 6 weeks, but all of a sudden not working.

Everytime i try php artisan key:generate i get an error No application encryption key has been specified. Ive added the key to the app.php to see if that works but nothing. Also tried to delete the forge site and reinstall form beginning and still fails.

Any ideas??

Also heres what happens if i just try artisan::

forge@app:~/testing.my-app.uk$ php artisan config:cache

In EncryptionServiceProvider.php line 42:
                                                     
  No application encryption key has been specified.  
                                                     

forge@app:~/testing.myapp.uk$ php artisan key:generate

In EncryptionServiceProvider.php line 42:
                                                     
  No application encryption key has been specified.  
                                                     
0 likes
4 replies
ccarver's avatar

Line 42 in the EncryptionServiceProvider is the exception thrown if the $config['key'] is empty. You should check your config file (app.php) for the 'key' value. Should be something like

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

If that is there, then check you .env file for the line

APP_KEY=base64:4X7.......

Hope that helps.

skoobi's avatar
Level 13

Hi @ccarver yep theres a key in the env file.

I just got it working again.

Had to::

git fetch --all

and then

git reset --hard origin/master

That randomly got it working even though i tried that a few times earlier. Just wondering if forge/Digital ocean cache setting or the env file or something?

Cronix's avatar

Just be careful and never alter your app_key once you start storing data or you won't be able to decrypt anything that was previously encrypted. Make sure you have that key backed up somewhere.

skoobi's avatar
Level 13

Ah cheers @Cronix i didn't know that one. I better back it up :)

Please or to participate in this conversation.