ホーム > Laravel > How to deal with the error "Your app key is missing" when running php artisan in Laravel
Laravel

How to deal with the error "Your app key is missing" when running php artisan in Laravel

Thank you for your continued support.
This article contains advertisements that help fund our operations.

⇨ Check out the table of contents for Laravel articles here

When you run php artisan in Laravel after cloning from Github, you may encounter the error "Your app key is missing." Here's how to handle it.

The full error message is as follows:

No application encryption key has been specified.

Your app key is missing
Generate your application encryption key using php artisan key:generate.

Conclusion

Running the command

php artisan key:generate

and putting the generated string into the line around line 3 of the .env file,

APP_KEY=

will resolve the issue.

(If you have created a Laravel project yourself, the string should already be filled in here, so there is no need to do anything special)

Explanation

When cloning a Laravel project from Github, etc., there is no .env file.

So, create an .env file by copying it from .env.example, for example.

However, in the initial state of .env.example,

APP_KEY=

is empty.

Laravel will throw an error if this is empty, so you need to run the command mentioned earlier.

Related articles

Solution when processing stops due to insufficient memory in EC2, Laravel, Queue

Troubleshooting when composer require command does not work well with versions in Laravel

Summary

That's it.

In a development environment, the answer is written on the error screen (php artisan key:generate), but I wrote this in case you might not notice it when you upload it to the server! I hope you find it helpful!

If you have any feedback, opinions, etc., please contact me via DM on Twitter.

That's all!

Popular articles

Deploying a PHP7.4 + Laravel6 project to AWS EC2

Implementing breadcrumbs in Laravel with laravel-breadcrumbs

Please Provide Feedback
We would appreciate your feedback on this article. Feel free to leave a comment on any relevant YouTube video or reach out through the contact form. Thank you!