DEV Community

Tao Liu
Tao Liu

Posted on • Edited on

There is no need for an .env file on Heroku.

heroku config:set VARIABLE=this_is_the_value

There is no need for an .env file on Heroku. In fact, such a file won't work very well since

Heroku gets all of its files from your Git repository,
has an ephemeral filesystem, meaning that changes to files like .env will be quickly lost, and
the .env file won't be available on other dynos if you scale your app
As such, creating an .env file on Heroku isn't a good approach.

Instead, you can use its built-in support for environment variables, using heroku config:set or its web UI. Either way, you'll get a regular environment variable.

https://stackoverflow.com/questions/49905070/how-to-add-env-file-or-otherwise-set-environment-variables-in-a-heroku-app

heroku config:set VARIABLE=this_is_the_value

Top comments (0)