Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Ligonsker's avatar

Random "production.ERROR: No application key has been specified." (In Local environment)

Hello,

I randomly get the following error:

"production.ERROR: No application key has been specified."

It doesn't bother much because the website just quickly refreshes, but I wonder where it comes from?

There is an application key and it happens randomly. Could that happen because I did not cache the config? Because I must not cache the config so I have to leave it un-cached

But also, why does it say production.ERROR if my APP_ENV is APP_ENV=local? (And when I type php artisan env it says that I'm really local)

Update: the env key in the app.php file is as follows:

'env' => env('APP_ENV', 'production')

It shows production there but the APP_ENV itself is set to local. But could that be the issue as well? That because I don't cache the config it sometimes tries to read the default?

Where should I look for to try to solve these 2 issues? (The wrong environment, and the random no app key errors?)

Thanks

0 likes
5 replies
Ligonsker's avatar

@vincent15000 Yes I know but it doesn't happen all the time so doesn't it mean it does manage to read the key when it doesn't fail? It happens only a few random times

1 like
NoLAstNamE's avatar

Maybe your .env is cached. Try running php artisan optimize:clear

2 likes

Please or to participate in this conversation.