.env/user_vars Environment Variables are returning NULL .env/user_vars Environment Variables are returning NULL nginx nginx

.env/user_vars Environment Variables are returning NULL


Sometimes when you changed in your .env file it does not take correct values from that, the problem is due to some configuration cache.Try running following commands, hope will work

php artisan config:cache   //cached all files under config directoryphp artisan config:clear   //repopulate all the env variable and clear config cachephp artisan cache:clear    //flush all the cached content (route, view, config cache)


It might be a little late but here is the answer. https://github.com/laravel/framework/issues/8191

As a summary it is suggested to set the value in your config file(I reference them to my env file). then you can call from config files. \Config::get('app.env') instead of env('APP_ENV') and in my app.php file in config folder I set:'env' => env('APP_ENV', 'production'),

php artisan config:cache did not solve my problem.

I hope it help you guys. cheers.


In your php.ini file check your variables_order. IF it reads "GPCS" try adding E to the beginning and restart your server, then see what happens.

If any of the lines in .env have spaces and aren't enclosed in " then it'll fail.

Some things to try

  • Check the permissions for your .env file. Try setting it to 777 as atest, to see what will happen. (if that works, don't keep it at 777)

  • Run php artisan config:cache, and php artisan config:clear command.

  • restart your app server.