# Cakephp 4 Error: setSalt() must be of the type string, null given

**URL:** <https://discourse.cakephp.org/t/cakephp-4-error-setsalt-must-be-of-the-type-string-null-given/7057>\
**Category:** Need Help\
**Created:** [January 4, 2020, 4:46pm UTC](https://discourse.cakephp.org/t/cakephp-4-error-setsalt-must-be-of-the-type-string-null-given/7057 "2020-01-04T16:46:48Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![cavatoni](https://avatars.discourse-cdn.com/v4/letter/c/a698b9/32.png) [@cavatoni](https://discourse.cakephp.org/u/cavatoni)\
**Post date:** [January 4, 2020, 4:46pm UTC](https://discourse.cakephp.org/t/cakephp-4-error-setsalt-must-be-of-the-type-string-null-given/7057/1 "2020-01-04T16:46:48Z")

</div>

Hello,  
I’m having a problem with my application while trying to migrate it to another computer.

I used cakephp 4 to implement, and the following error message appears when running the application on another computer:

> Argument 1 passed to Cake \ Utility \ Security :: setSalt () must be of the string type, null given, called in /…/config/bootstrap.php on line 164

Bootstrap.php line 164 is this:

> Security :: setSalt (Configure :: consume (‘Security.salt’));

Why is the argument coming _null_?

I don’t know what else to do.

Thank’s a lot

---

<div class="post-metadata">

**Author:** ![dakota](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/dakota/32/1421_2.png) [@dakota](https://discourse.cakephp.org/u/dakota)\
**Post date:** [January 5, 2020, 7:32pm UTC](https://discourse.cakephp.org/t/cakephp-4-error-setsalt-must-be-of-the-type-string-null-given/7057/2 "2020-01-05T19:32:29Z")

</div>

In your `app.php`, is there a value for `salt`?

---

<div class="post-metadata">

**Author:** ![cavatoni](https://avatars.discourse-cdn.com/v4/letter/c/a698b9/32.png) [@cavatoni](https://discourse.cakephp.org/u/cavatoni)\
**Post date:** [January 6, 2020, 1:47am UTC](https://discourse.cakephp.org/t/cakephp-4-error-setsalt-must-be-of-the-type-string-null-given/7057/3 "2020-01-06T01:47:55Z")

</div>

Yes,

> ‘Security’ =\> [  
> ‘salt’ =\> env(‘SECURITY\_SALT’),  
> ],

Is this correct?

Thanks

---

<div class="post-metadata">

**Author:** ![cavatoni](https://avatars.discourse-cdn.com/v4/letter/c/a698b9/32.png) [@cavatoni](https://discourse.cakephp.org/u/cavatoni)\
**Post date:** [January 6, 2020, 2:01am UTC](https://discourse.cakephp.org/t/cakephp-4-error-setsalt-must-be-of-the-type-string-null-given/7057/4 "2020-01-06T02:01:17Z")

</div>

Problem solved.  
I created the SECURITY\_SALT environment variable with a random value, and it worked.

Thanks a lot!!!

---

<div class="post-metadata">

**Author:** ![leipomalla](https://avatars.discourse-cdn.com/v4/letter/l/c0e974/32.png) [@leipomalla](https://discourse.cakephp.org/u/leipomalla)\
**Post date:** [February 1, 2020, 2:26pm UTC](https://discourse.cakephp.org/t/cakephp-4-error-setsalt-must-be-of-the-type-string-null-given/7057/5 "2020-02-01T14:26:00Z")

</div>

I’m having the same problem and I don’t seem to get it right by using cavatoni’s way. Any other suggestions what to do? Mentioned parts in app.php and bootstrap.php are just like cavatoni’s. CakePHP version id 4.0.

I am new with cake and just starting with blog tutorial, so please bear with me 🙂

Thanks!

---

<div class="post-metadata">

**Author:** ![cavatoni](https://avatars.discourse-cdn.com/v4/letter/c/a698b9/32.png) [@cavatoni](https://discourse.cakephp.org/u/cavatoni)\
**Post date:** [February 1, 2020, 3:16pm UTC](https://discourse.cakephp.org/t/cakephp-4-error-setsalt-must-be-of-the-type-string-null-given/7057/6 "2020-02-01T15:16:25Z")

</div>

Hello,  
there’s another way.  
You can edit app.php (near to 78 Line):

> ‘Security’ =\> [  
> ‘salt’ =\> env(‘SECURITY\_SALT’, ‘dfc123c6c22d84f4bc12273f3df67c6ae55009696e4126b36ac2f755778faccc’),  
> ]

Use another string hash for your application, it will work.

---

<div class="post-metadata">

**Author:** ![leipomalla](https://avatars.discourse-cdn.com/v4/letter/l/c0e974/32.png) [@leipomalla](https://discourse.cakephp.org/u/leipomalla)\
**Post date:** [February 1, 2020, 3:37pm UTC](https://discourse.cakephp.org/t/cakephp-4-error-setsalt-must-be-of-the-type-string-null-given/7057/7 "2020-02-01T15:37:51Z")

</div>

Thank you!

I got that one straight, mut now my database connection is not working. My problems seem to be somewhere else…

But it good to know that one get´s a fast answer here!
