Error : The MAC is invalid Question's And Solutions [Solved]

  • 23-06-2022
  • 995
  • Laravel 9
  • Haresh Chauhan

The problem occurs when you generated new APP_KEY in your laravel application or when you change your laravel application .env file.

The APP_KEY is very important in your laravel application. without this key you can not able to open your application. You must need to generate "KEY". Then your application will run.

The command of key generate is :

php artisan key:generate

So Next, If you are facing MAC is invalid error when you trying to open your laravel application. So i will give you solution for that.

Before that, I want to ask some Questions :

  • Have You Change Your .env file?
  • Have You Generated New Your APP_KEY using Command?
  • Have You Made Any Changes/Replaced In APP_KEY?
  • The Encrypted Value, You Made Any Changes?
  • Have Your Copy Of The Data Value From Other Which You Try To Decrypt?
  • The Variable Value Is Null Or Not Encrypted?

If Your answer is "YES" then please follow the below solution.

The MAC is invalid

Below Solution will help you to slove your problem.


Please add Old APP_KEY As it is Before you used. If you have!.


You can again Encrypt your value which you trying to Decrypt old encrypted value with new APP_KEY.


Make Sure Your Production and Staging APP_KEY in the .env file are the same.


Make sure the variable value that you trying to Decrypt is NOT NULL.


Check the value of the variable which you trying to Decrypt is Encrypted Before.


Encrypt that value with new APP_KEY.

We always thanks to you for reading our blogs.


Dharmesh Chauhan

(Swapinfoway Founder)

Hello Sir, We are brothers origin from Gujarat India, Fullstack developers working together since 2016. We have lots of skills in web development in different technologies here I mention PHP, Laravel, Javascript, Vuejs, Ajax, API, Payment Gateway Integration, Database, HTML5, CSS3, and Server Administration. So you need our service Please Contact Us


Haresh Chauhan


We Are Also Recommending You :