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

Roni's avatar
Level 33

.env file and config keys not updating after change.

Working on a Laravel / InertiaJS project. And I tried to get email verification working.

It was blowing up with a 530 response, unauthenticated. I hadn't set my .env properly. However, now that all the .env is set, it still is not updating.

I've tried valet restart, which reloads php and nginx

tinker

>>> config('mail.driver');
=> "smtp"
>>> config('mail.host');
=> "smtp.mailtrap.io"
>>> config('mail.username');
=> null

.env (I've regenerated)

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=e4dc552c4e0aed
MAIL_PASSWORD=387781a27fccfe
[email protected]
MAIL_FROM_NAME=Example

config/mail.php

'username' => env('MAIL_USERNAME', 'e4dc552c4e0aed'),
'password' => env('MAIL_PASSWORD', '387781a27fccfe'),

I feel so weird, like how can this be happening to me? @reinink, I know before I ask, could this have anything to do with inertia? But I'm so confused over this I have to ask anyhow.

0 likes
7 replies
Tangente's avatar
Tangente
Best Answer
Level 9

By the way, every time you change .env file, make sure you clear cache

php artisan cache:clear
php artisan config:clear
php artisan route:clear

I'm not sure if that is the problem, but make sure you do that every time you change values in .env file

4 likes
Roni's avatar
Level 33

Thank you, I've been pulling out hair!

1 like
masiorama's avatar

I am having the same issue but it seems that clearing cache as @tangente suggested does not work. The only major difference from @roni scenario is that I am accessing a schedule task, but I don't think this should change the thing. ps: I am on laravel 8.

mugukamil's avatar

@masiorama hey mate, I have the same problem, I got this problem after amazon elastic beanstalk updated my environment or instance, now all my env() variables returns empty or default option

umefarooq's avatar

if you are using laravel queue and supervisor for sending emails you need to restart supervisor process to take latest config or code changes. you can restart supervisor processes with following command

supervisorctl restart laravel-worker:*

2 likes
malltin's avatar

@umefarooq I have a problem with changing mailtrap configuration in my Laravel app, after changing the .env config for email, laravel app uses the previous username and password for mailtrap account, after restarting supervisor workers it worked for me.

Please or to participate in this conversation.