# APP\_KEY encryption key issue, intermittent GET error 500

**URL:** <https://community.dreamfactory.com/t/app-key-encryption-key-issue-intermittent-get-error-500/2878>\
**Category:** App Configuration\
**Created:** [June 22, 2016, 7:37pm UTC](https://community.dreamfactory.com/t/app-key-encryption-key-issue-intermittent-get-error-500/2878 "2016-06-22T19:37:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sdev](https://avatars.discourse-cdn.com/v4/letter/s/ea666f/32.png) [@sdev](https://community.dreamfactory.com/u/sdev)\
**Post date:** [June 22, 2016, 7:37pm UTC](https://community.dreamfactory.com/t/app-key-encryption-key-issue-intermittent-get-error-500/2878/1 "2016-06-22T19:37:36Z")

</div>

The Angular2 sample app intermittently fails to retrieve all “Contacts” for the selected “Group”, but some rows remain empty. It is different every time you click, sometimes it happens that all rows are fetched. API call example: `local.INFO: [REQUEST] {"API Version":"2.0","Method":"GET","Service":"db","Resource":"_table/contact/99"}`  
For all empty rows the [installdir]\ apps\dreamfactory\htdocs\storage\logs\dreamfactory.log says:

`production.ERROR: exception 'RuntimeException' with message 'No supported encrypter found. The cipher and / or key length are invalid.' in ... Illuminate\Encryption\EncryptionServiceProvider->getEncrypterForKeyAndCipher('SomeRandomStrin...', 'AES-256-CBC')`

Actually it is a laravel bug: [http://laravel.io/forum/06-09-2015-no-supported-encrypter-found-the-cipher-and-or-key-length-are-invalid](http://laravel.io/forum/06-09-2015-no-supported-encrypter-found-the-cipher-and-or-key-length-are-invalid), and the solution which works for me is to alter this line in the [installdir]\apps\dreamfactory\htdocs\config\app.php in line 78  
from:  
`'key' => env('APP_KEY', 'SomeRandomString'),`  
to:  
`'key' => env('APP_KEY', 'SomeRandomString1234567890123456'),`

After editing this, execute: `php artisan config:clear`, `php artisan cache:clear`, and `php:artisan key:generate` and then restart the DF stack.

The bug is there in version dreamfactory-2.2.0-0.

---

<div class="post-metadata">

**Author:** ![sdev](https://avatars.discourse-cdn.com/v4/letter/s/ea666f/32.png) [@sdev](https://community.dreamfactory.com/u/sdev)\
**Post date:** [June 22, 2016, 10:06pm UTC](https://community.dreamfactory.com/t/app-key-encryption-key-issue-intermittent-get-error-500/2878/2 "2016-06-22T22:06:16Z")

</div>

Now I fixed that, but I get “MAC is invalid.” in DF admin application. It seems like this: [“MAC is invalid” 500 Error when upgrading from 2.01 to 2.1](https://community.dreamfactory.com/t/mac-is-invalid-500-error-when-upgrading-from-2-01-to-2-1/2220)

So, the question is how to fix the initial issue, and not spoil the latter.

---

<div class="post-metadata">

**Author:** ![sdev](https://avatars.discourse-cdn.com/v4/letter/s/ea666f/32.png) [@sdev](https://community.dreamfactory.com/u/sdev)\
**Post date:** [June 24, 2016, 6:06pm UTC](https://community.dreamfactory.com/t/app-key-encryption-key-issue-intermittent-get-error-500/2878/4 "2016-06-24T18:06:38Z")

</div>

Simply put:  
A bug requires change of APP\_KEY, but changing APP\_KEY causes issues in the admin app.

Any ideas?

---

<div class="post-metadata">

**Author:** ![sdev](https://avatars.discourse-cdn.com/v4/letter/s/ea666f/32.png) [@sdev](https://community.dreamfactory.com/u/sdev)\
**Post date:** [July 2, 2016, 10:16pm UTC](https://community.dreamfactory.com/t/app-key-encryption-key-issue-intermittent-get-error-500/2878/5 "2016-07-02T22:16:22Z")

</div>

No ideas yet?  
If not, this means that in this version we need to choose if we prefer the admin app to work okay, or the example apps (and possibly others that we create).

---

<div class="post-metadata">

**Author:** ![formerstaff](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/formerstaff/32/1133_2.png) [@formerstaff](https://community.dreamfactory.com/u/formerstaff)\
**Post date:** [July 15, 2016, 3:52pm UTC](https://community.dreamfactory.com/t/app-key-encryption-key-issue-intermittent-get-error-500/2878/6 "2016-07-15T15:52:24Z")

</div>

I don’t have any experience with the laravel bug you referenced, however if you wish to change your app key, you will get MAC is invalid errors because items that are stored in the system database with two way encryption use the app key for that encryption.

You can resolve the MAC is invalid error by deleting any service configurations that have stored credentials from the database, as well as any private lookups. (These are the only items in the DB affected by the app key change.)

For example, sql service configs are stored in the table sql\_db\_config  
Go in and set the username and password fields for these to NULL.  
After you change the app key, you can resave the credentials.
