I've deployed an app to Heroku, and I'm currently storing my environment variables in an .env file. I used heroku config:push
to push the variables up to heroku, and that worked fine.
Now, I want to update one of them. I changed it in my .env file, and ran heroku config:push
again. The push said it was successful, but when I run heroku config
, I can see that the values actually haven't changed. I've tried running heroku restart
, but that didn't do anything.
How can I update my environment variables in heroku?
One way of setting the environment variables on Heroku is to use the web interface. The first step is to log into your account and go to the Heroku dashboard. Figure 1 illustrates my dashboard. Choose the application for which you want to set the environment variables.
env file on Heroku isn't a good approach. Instead, you can use its built-in support for environment variables, using heroku config:set <var> <value> or its web UI. Either way, you'll get a regular environment variable.
Heroku config vars are designed to be safe for storing sensitive information. All config vars are stored in an encrypted form and safely stored. These are only decrypted and loaded when booting your app in a dyno itself.
Figured it out. You need to run heroku config:push --overwrite
because it won't overwrite existing variables by default. This is poorly documented :-/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With