When configuration is cached, Laravel does not reload .env during requests. Long-running processes such as queue workers, Octane or PHP-FPM may also retain old configuration in memory.
php artisan config:cache
.env changed
Application still uses old DB_HOST
php artisan optimize:clear
Laravel config:cache combines all configuration into one cached file and .env is no longer loaded on subsequent requests. Therefore env() should not be called outside configuration files; application code should read values through config(). Long-running workers must also be restarted.
Move env() into a configuration file.
$adres = env('API_URL');$adres = config('services.api.url');Code updates and cache rebuilds should be deployed together.
git pull
composer installgit pull
composer install --no-dev --optimize-autoloader
php artisan optimize:clear
php artisan optimizeNew jobs should start with the updated configuration.
.env değişti fakat worker çalışmaya devam ediyorphp artisan queue:restartChecks the active environment and generated cache files.
php artisan about --only=environment
php artisan config:show database
ls -lah bootstrap/cache
Clears configuration, route, event and view optimization caches.
php artisan optimize:clear
Run after verifying the application does not contain non-cacheable route closures.
php artisan config:cache
php artisan route:cache
php artisan view:cache
Run only the commands relevant to your stack.
php artisan queue:restart
php artisan octane:reload 2>/dev/null || true
systemctl reload php8.3-fpm
Identify the stale value using config:show.
Find env() calls outside configuration files.
Move values to config/services.php or the appropriate configuration file.
Run optimize:clear and verify the new .env value.
Rebuild production cache files.
Reload queue, Octane and PHP-FPM processes in a controlled manner.
env() is called outside config files while configuration is cached.
bootstrap/cache/config.php contains the old value.
The worker is still running with old in-memory configuration.
A non-cacheable route closure or unserializable structure exists.
No matching error was found.
If configuration is cached, it must be rebuilt. In development without config cache, most values are read on the next request.
config:clear is enough for configuration only. optimize:clear is broader and removes Laravel optimization caches after deployment.
Not for every .env change; a controlled reload may be needed when OPcache, preload or long-running processes retain stale code or values.
We implement permanent fixes by reviewing Laravel, PHP-FPM, Nginx, Apache, MySQL, cPanel and Plesk layers together with their logs.