---
title: "Discussion on \"Laravel .env Changes Not Working? Fix the config:cache Trap\" | Hashnode"
description: "Discussion on \"Laravel .env Changes Not Working? Fix the config:cache Trap\". Why config:cache stops Laravel from reading .env, why env() returns null outside config files, and the right command order after every deploy."
url: "https://hashnode.com/posts/laravel-env-changes-not-working-config-cache/6ae1a5f558bdea6c6b0f5a8d"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Laravel .env Changes Not Working? Fix the config:cache Trap](https://capcodetech.hashnode.dev/laravel-env-changes-not-working-config-cache?utm_source=hashnode&utm_medium=feed)

Why config:cache stops Laravel from reading .env, why env() returns null outside config files, and the right command order after every deploy.

Oct 28 · 12 min read · capcodetech.hashnode.dev  
Read the article

-   [#laravel](https://hashnode.com/tag/laravel)
-   [#php](https://hashnode.com/tag/php)
-   [#deployment](https://hashnode.com/tag/deployment)
-   [#devops](https://hashnode.com/tag/devops)
-   [#web-development](https://hashnode.com/tag/web-development)

## Written by

[Captain Code](https://hashnode.com/@capcodetech)

@capcodetech · Iran

  
[View profile](https://hashnode.com/@capcodetech)

Laravel, TALL stack & AI tools — captaincode.tech

## Responses 1

Markdown supported · ⌘↵ to post

[Kamran Khan](https://hashnode.com/@kamrankhandev)

[Oct 29](https://hashnode.com/posts/laravel-env-changes-not-working-config-cache/6ae1a5f558bdea6c6b0f5a8d/comment/6ae34667a689abae0d3f5f8b)

The diagnose-first order is the part I would keep. I have wasted more time clearing every cache than I ever saved, and checking whether the config is actually cached usually points straight at the stale file. The case that still catches me is a queue worker that was never restarted, because the web request looks fixed while jobs keep sending mail with the old host. I now treat an .env change as a deploy, not a quick server edit, and I do not consider it done until the worker restart is confirmed.
