Set Up Nightscout Using Heroku

18 Feb
Guides > Setup Guides > Set Up Nightscout Using Heroku

Heroku is an alternative to Azure for hosting of your Nightscout site. Pricing has changed over the last few years, but currently (2017), Heroku is again free to use for a 24×7 site.

The following directions specifically guide you through setting up a Nightscout site (for the first time) on Heroku.

IMPORTANT NOTE: Heroku automatically creates an mLab database for you during the setup process. You do not need to set up mLab separately. With the Deploy to Heroku setup, the mLab portion will be handled automatically. (If you want to use an mlab database from another site, you can replace the mongo information after the site deploys by going into the settings for your Heroku site, clicking to “Reveal the Config Variables,” and replacing the mongo information with your existing mongo string.)

To create your Nightscout website on Heroku:

  1. Create a GitHub account and your own fork of the CGM-Remote-Monitor. (This process is described in Step 1 on this page. Complete Step 1 and return this this page for Heroku setup.)
  2. Create a Heroku account. (Directions not provided. Follow the directions at Heroku to set up an account.)
  3. Go to your GitHub account, and select the CGM-Remote-Monitor.
  4. In the repository, scroll down to the file, and click the purple “Deploy to Heroku” button. (Scroll down to it; do not click it from the list. If you click the link in the list and then try the purple button, you will see this error: “No app.json located in the repo URL provided.” Scroll down to the purple “Deploy to Heroku” button instead.)
    Heroku - Deploy
  5. On the Heroku screen that opens, fill in the information requested:
    • App Name: this will be the name of your site (part of the URL)
      Heroku - Site Name
    • Config Variables: many of these you can adjust later, once your site is up and running, but you need to deal with a few of them during setup:
      • Mongo Collection: leave it at the default “entries”
      • API Secret: Enter a “secret” passphrase you will use for your site. It must be at least 12 characters. Be sure and write it down.
      • ENABLE: This is the variable that turns on all the features you want to use. There are many possible features and plugins available! To get started, try turning on popularly uses plugins by typing this string in, a space between each word, as shown: careportal basal bwp iob cob cage sage iage azurepush (If you know that you are setting up a “bridge” site, also enter the word bridge. If you have an Alexa and want to use it with Nightscout, also enter alexa.)
      • DISPLAY_UNITS: Enter your default display units. Choices: mg/dl (the default) or mmol.
      • BRIDGE_USER_NAME and BRIDGE_PASSWORD: If you are setting up a bridge site, enter the Dexcom user information in these fields. (If you are outside of the U.S., you also need to add the BRIDGE_SERVER variable with EU as the value.)
  6. After you have filled in your variables, click the big “Deploy” button at the bottom of the screen.
  7. Heroku will begin deployment, which you will see in a box at the bottom of the page.
    Heroku - Running
  8. Be patient. This can take several minutes.
  9. Once Heroku tells you the app has been successfully deployed, click the “View” button to open the site in a browser. If the deployment was successful (and there are no errors with the variables you input), the site will be black with time and dashes. Once data is available from the uploader, data will show.
    Heroku - Success
  10. Your website url takes this format:
Note: a “profile” is required for you to view your site. The very first time you visit the site, you will be prompted to create a profile. Enter your API SECRET to authenticate your site. Then, at the minimum, select the timezone and “save” the profile. (You can always edit it later.) Return to another browser window and load your site (or enter your url again in the same window and hit enter).

Configuring the site

There are additional variables you may want/need to set later. To do so, return to your Heroku dashboard. Click “Settings,” and then click “Reveal config variables” to access the variables and make changes or additions.

Deploying a different branch

If (at any point) you need to deploy a different branch to your existing Heroku site:

  1. Click the “Manage App” button (or navigate to your app from the dashboard)
  2. Click the “Deploy” tab.
  3. If your app shows that it is connected to GitHub:
    • At the bottom of the screen, under the heading “Deploy a GitHub branch,” select the branch (e.g., “dev”) from the drop-down list.
    • Click “Deploy Branch.”
    • Wait for the deployment to fully finish, and try to view the app (use the button or open your Heroku url in another browser tab).
  4. If your app doesn’t appear to be connected to Github:
    • Click “GitHub” next to “Deployment Method.”
    • Enter your GitHub user name in the first box next to “Connect to GitHub” and enter “cgm-remote-monitor” in the next box.
    • Click “Search.”
    • Select your repository and click “Connect.”
    • At the bottom of the screen, under the heading “Deploy a GitHub branch,” select the branch (e.g., “dev”) from the drop-down list.
    • Click “Deploy Branch.”
    • Wait for the deployment to fully finish, and try to view the app (use the button or open your Heroku url in another browser tab).

Bridge Users

Note: If you are setting up a bridge site, be sure you set up and configure Uptime Robot. [If you do not do this, your bridge will not stay awake properly.]

Configuring Your Uploader

Depending on your uploader app, you may need to configure the app to use REST API for uploading data to your Nightscout site. The sample syntax shown in your app may show the format for an Azure site. A Heroku site takes this format: