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

ioiofadhil's avatar

Laravel sometimes not reading ENV right in Development. Why?

I'm building an App with React and Laravel. My Dashboard (react) has many queries to Laravel (each widget, something like that). Sometime, Laravel just not read the env right in couple of fetches.

SQLSTATE[HY000] [1045] Access denied for user 'forge'@'localhost' (using password: NO) (Connection: mysql, SQL: select * from `personal_access_tokens` where `personal_access_tokens`.`id` = 49 limit 1)

I tried something like clearing cache of env. But it's still happening couple of times. It's so annoying. What's happening?

note: Production is good.

0 likes
2 replies
manishchauhan's avatar

check that your local .env file contains the correct database credentials and matches what you have in your config/database.php

or run command php artisan config:clear php artisan cache:clear

Snapey's avatar

@manishchauhan

and matches what you have in your config/database.php

What? That makes no sense.

1 like

Please or to participate in this conversation.