Sales funnel content here linking back to main marketing website Code Institute
The Library
    • All Posts

    • Bootstrap
    • Careers
    • Django
    • Git & GitHub
    • Heroku
    • IDE
    • JavaScript
    • MongoDB
    • README.md
    • Resources
    • Troubleshooting
    • Account

    • Log in
    • Create account

Setting config / environment variables on Heroku

Written by: anna_ci
|
Published: Aug. 17, 2021
Heroku

When working on your project, your code has two separate environments. Your local one, within your IDE, and the deployed environment on Heroku.If you have followed good practice, you have set up your environment variables for your project in a file that is not sent to git.

As Heroku uses your repository code to build the deployed site, it won't have access to those environment variables in your local file, and it will throw errors at you. So when deploying, it is important to give Heroku its own copy of your environment variables. To do this:

  • Log into Heroku
  • Open the app dashboard for your Heroku app
  • Click on Settings
  • Click on Reveal Config Vars

Make sure you have set:
IP as the key with a value of 0.0.0.0
PORT as the key with a value of 8080

You can add any other environment variables the project needs in the same way. So for example, if you have set your local environment variable of SECRET_KEY = "whatever" then add them to the Heroku config vars too. with SECRET_KEY as the key with a value of whatever (without the "" around it)

More on how to set environment variables here: https://code-institute-room.slack.com/archives/CP07TN38Q/p1576743956008500

Image to accompany post
Click on a thumbnail to enlarge
Modal title
More posts about Heroku

About the Author

anna_ci

Anna Greaves

Content Developer | Software Developer

Visit Profile

Tags

deployment environmentVariables heroku mongoDB projects
Code Institute Courses
Info about the difference between the 2 courses here.
  • All Posts |
  • Categories |
  • Search

Policies

  • Terms and Conditions
  • Privacy Policy
  • Plagiarism Policy
  • FAQs

About

Lorem ipsum dolor sit amet consectetur adipisicing elit. Soluta, omnis fuga cupiditate sit perferendis culpa at vitae officiis molestias, dolores nihil repellendus odio? Praesentium voluptas iusto numquam incidunt error unde?