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

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

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


‘Security’ => [
‘salt’ => env(‘SECURITY_SALT’),

Is this correct?


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

Thanks a lot!!!

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 :slight_smile:


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.

1 Like

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!