When you create variables in .env you need to source that too so it will work in your project directory by running the following command in terminal
source .env
if .env is in any folder e.g config/.env then
source config/.env
I had a same issue with little research its fixed with this command.