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

timgavin's avatar

Forge .env not working properly

I set up a server on Forge and have noticed that the only way I can get beanstalkd and a few other things to work is if I hardcode them into the app's config files rather than in the site's .env file, which, obviously is not optimal.

Anybody else have this issue or know of any fixes?

0 likes
12 replies
willvincent's avatar

Are you certain the .env file is in place on the server.. and has proper permissions?

timgavin's avatar

@willvincent Yep, it's in the proper place and has 664 perms. Forge created it for me; so I would hope that's correct. :)

Also, some of the settings do work, and some - like beanstalkd - do not.

.env
app
boostrap
public
resources
... etc.
willvincent's avatar

Interesting.. are you sure the config files handling those settings that are not working are setup to use .env values?

timgavin's avatar

Yep! This is what I have on my server. It won't work using the value in .env, which is QUEUE_DRIVER=beanstalkd

'default' => env('QUEUE_DRIVER', 'beanstalkd'),

Yeah, it's weird...

willvincent's avatar

No excess spaces or anything anywhere in that .env file either?

Maybe it's a caching issue?

ejdelmonico's avatar

Did you run php artisan config:clear? Also, run php artisan cache:clear And, it may be your site path is not correct if the .env is not found in the root.

2 likes
squibby's avatar

Whenever change .env variables in forge, ssh to your server and run php artisan config:cache. This will clear the cached config files then look to .env and create new ones with the new variables. I had this problem before and that always updates it.

If you want to check it worked, run php artisan tinker, then use the config helper function to view any config file and see if it has changed properly.

3 likes
timgavin's avatar

@squibby Yeah, I found restarting the server would make the changes stick. This is better, thanks. :)

tristanbailey's avatar

Not on forge, but a DigitalOcean server and there were no values in $_ENV or env() not sure for how long, and running php artisan config:clear got them back again, after some head scratching, so thanks

ejdelmonico's avatar

Laravel caches your config key/value pairs. Anytime you change something in the .env file, you should run php artisan config:clear and then if you chosse to force the caching php artisan config:cache

Please or to participate in this conversation.