Nightscout in Railway


Too complicated? Not what you’re looking for?

Consider a hosted Nightscout service! Check for easier solutions here.


Warning

The free plan has been removed Jul 3rd for new users and Aug 1st for existing users.


Railway.app

Railway

You can easily create a new Railway Nightscout site with a MongoDB Atlas database or a Railway MongoDB database.

Pros:

  • Nightscout fits in the 5$/month Hobby account

  • Easy to deploy or migrate an existing site from Heroku

  • Simple to use and troubleshoot

  • You can host several Nightscout sites within a single Hobby account

  • Can use a native Railway MongoDB database ($)

Cons:

  • Your GitHub account must have been created more than 3 months ago

  • The railway.app domain is blocked for safety by some companies

  • Railway network model causes issues with some follower app and devices


Set up a new Nightscout

Create your Railway and GitHub accounts from a computer.

Note

Do not change device/computer/browser during the setup process!
If you have unexpected issues when creating your site, restart with another browser.


Step 0: Create a database

Note

Make sure you created one before starting your Nightscout web app creation with Railway. Come back here when you have a MONGODB_URI connection string.

Migrating?

Copy the connection string from your previous platform: edit the variables and look for MONGODB_URI. If you don’t see MONGODB_URI but see MONGO_CONNECTION (NOT MONGO_COLLECTION): use its value.


Step 1: Fork cgm-remote-monitor

Do you have a GitHub account?

You cannot connect Railway to GitHub if you just created your account.
Your GitHub account needs to have been created months ago.

../../../_images/RailwayGitHub.png

Consider another platform.

Update your Nightscout fork

  • Click here to log in at GitHub: https://github.com/login.

  • Enter your username or email and your password. Click Sign in

../../../_images/UpdateNS00.png

  • Select your own cgm-remote-monitor project (not nightscout/cgm-remote-monitor)

../../../_images/UpdateNS01.png

  • Your repository will open. If you see This branch is xxx commits behind nightscout:master you need to update.

  • Select Fetch upstream

../../../_images/UpdateNS01a.png

  • Select Fetch and merge

../../../_images/UpdateNS01b.png

  • After a moment, your repository should display This branch is up to date with nightscout:master

../../../_images/UpdateNS01c.png

You have now updated your GitHub cgm-remote-monitor repository.


If you ran into trouble, you can redeploy the project.



Step 2: Create a Railway account

If you already have a Railway account, make sure you have a developper plan: go to step g).


a) Open Railway in a new browser tab and click login. Login with GitHub.

../../../_images/Railway00.png ../../../_images/Railway01.png

b) If the following screen shows-up, select Authorize Railway App.

../../../_images/Railway02.png

c) Click on Please agree to the new terms to keep on using Railway.

../../../_images/Railway03.png

d) Scroll down and click I agree with Railway's Terms of Service.

../../../_images/Railway04.png

e) Scroll down and click I will not deploy any of that.

../../../_images/Railway05.png

Danger

The free plan will be removed Jul 3rd for new users and Aug 1st for existing users.
Documentation will be updated.


f) You should now see this. You’ve created your Railway account.
If it still shows 200 hours, refresh your browser page.

../../../_images/Railway06a.png

g) You need to use Nightscout for more than one month: upgrade your account to a Hobby plan. Click on the Starter Plan information and select Remove Resource Limits.

../../../_images/Railway06b.png

Enter your credit card information and select Subscribe to a Hobby Plan.

../../../_images/Railway06c.png

Your card will be billed 1$ that will be refund immediately. Bank fees won’t be refund.


Step 3 - Deploy Nightscout in Railway

Select below how you want to do this:


a) Click on the Deploy on Railway button below:

Deploy on Railway

Note: this is a private template as the community doesn’t have a Railway account.
It doesn’t include any referral code.


b) If you see this screen, select Connect GitHub to Deploy.

../../../_images/Railway07a.png

Then select Authorize Railway App.

../../../_images/Railway02.png


c) Click Configure

../../../_images/Railway07.png


d) Click Install & Authorize

../../../_images/Railway08a.png


e) You will then see this page, scroll down to define the required variables for creating your Nightscout site.

../../../_images/Railway09.png


Mind if you see this you must delete thecgm-remote-monitor fork in GitHub and retry Deploy from a) afterwards.

../../../_images/Railway17.png


f) Setup your Nightscout core variables.

Migrating from Heroku

If you’re migrating your project from Heroku, display all variables in Heroku and copy all those with a value into Railway.
See below how to add variables in Railway but use your Heroku variables values.

API_SECRET will be your Nightscout site password, it needs to be at least 12 characters long and you should NOT use spaces if you use @ or ! symbols remember you will probably need to express them using Percent encoding in your uploader and downloader apps. If you’re not sure on how to do this, it is recommended to use only letters (uppercase + lowercase) and digits.

Warning

The API_SECRET is the main password allowing full access to your Nightscout site. Make sure it’s reasonably secure (mix uppercase and lowercase letters, plus digits) and do no not share it publicly. If you think you exposed it by mistake, it is recommended that you change it.

../../../_images/Railway10.png

g) At Step 3 you created your database and came back with a MONGODB_URI string. Time has come to use it here.

../../../_images/Railway21.png


Dexcom Bridge

h) If you use Dexcom bridge you need to configure these two variables with your Dexcom credentials:

../../../_images/Railway33.png

../../../_images/Railway34.png

If you’re using Dexcom Share in the US you should put US, in any other case it must be EU.
If you don’t see it proposed at this point you’ll need to browse the list below to find it and modify it.

../../../_images/Railway36.png

Remember to add bridge at the end of the enable variable in the list below.


MOST COMMON ERRORS

The most common error on initial Nightscout setups is that people incorrectly use an old account or an old password. To test your username and password, go to Dexcom’s Clarity page (check here for USA accounts and here for the others) and try logging in to your Dexcom account. If your account info isn’t valid, or you don’t see any data in your Clarity account… you need to figure out your actual credentials before moving ahead. See here for troubleshooting tips and information on your Dexcom account.

Password

Some people have had problems with their bridge connecting when their Dexcom passwords are entirely numeric. If you have connection issues in that case, try changing your password to something with a mix of numbers and letters.

Hint

You need to have at least one follower to use Dexcom Share. See here.


i) Many optional variables are already setup for you, open the caret to see them and eventually modify them (recommended).

../../../_images/Railway15.png


Select the units you’re using in DISPLAY_UNITS acceptable choices are mg/dl or mmol/L (or just mmol).

../../../_images/Railway13.png


You can update the alarms values. See here for the meaning of each one.

../../../_images/Railway37.png


If you want to ensure that ONLY someone with permission to view your site (e.g., a token or the API_SECRET) is able to view the data, you should configure the AUTH_DEFAULT_ROLES variable in as denied.
If you want your site to be visible to anybody leave it as readable.

../../../_images/Railway11.png


A common list of enable variables is predefined, you can change them if you know why.
It’s recommended that you leave them like this for now.

Just remember to add bridge at the end if your get your BG values from Dexcom Share.

../../../_images/Railway14.png


You can modify the variables values, check the documentation for the meaning of each one.
Make sure you don’t make typo errors, some will crash your site (like for example LANGUAGE value in upercase).


j) You can now Deploy, and wait until it is complete.

../../../_images/Railway16.png

If you see this message, deploy didn’t complete, let’s fix this manually.

../../../_images/Railway41.png

j1) Select Settings and scroll down to Service.
Disconnect your Source Repo with the cross at the end of the line.

../../../_images/RailwayT01.png

j2) Confirm Disconnect.

../../../_images/RailwayT02.png


j3) Select Connect Repo.

../../../_images/RailwayT03.png

You should be able to select your GitHub cgm-remote-monitor repository.

../../../_images/RailwayM03.png

Your Railway app will now automatically deploy.


a) Click on Create a New project.

../../../_images/Railway06.png

If you don’t see that, top right, click + New Project.

../../../_images/RailwayDB01.png


b) Select Deploy from GitHub repo.

../../../_images/RailwayM19.png


c) Select Configure GitHub App.

../../../_images/RailwayM02.png


d) Choose Only select repositories, in the Select repositories drop-down select your own fork of cgm-remote-monitor.
Then, at the bottom, click Install & Authorize.

../../../_images/Railway08.png


e) You should be back to Deploy from GitHub repo, select it.

../../../_images/RailwayM19.png


f) Now you can select your own GitHub repository.

../../../_images/RailwayM03.png


g) Select Add variables.

../../../_images/RailwayM20.png


h) The Nightscout project will deploy in the background, just ignore it: now we need to setup our Nightscout variables.
Click on Raw Editor.

../../../_images/RailwayM21b.png

The raw editor will open, leave it like this for now.

../../../_images/RailwayM21c.png


i) Compile the information below.

File all necessary fields, click on the Validate button at the bottom of the form, if no error is seen you will have all variables displayed in the text box at the bottom, click on the Copy All button.

../../../_images/Railway42.png

Mandatory variables

These three variables below must have a value.

MONGODB_URI

The MongoDB Connection String to connect to your MongoDB cluster. If you don’t have this from your Mongo database, please re-read installation instructions at Nightscout database before continuing


API_SECRET


A passphrase that must be at least 12 characters long. Avoid special characters, which can cause problems in some cases

DISPLAY_UNITS



Preferred BG units for the site: `mg/dl` or `mmol/l` (or just `mmol`)

Customizations

Leave default values if you don’t want to change them

CUSTOM_TITLE


The display name for the Nightscout site. Appears in the upper left of the main view. Often set to the name of the CGM wearer

THEME



Default setting for new browser views for the color theme of the CGM graph. (`default` `colors` or `colorblindfriendly`)

ENABLE


Plugins to enable for your site. Must be a space-delimited lower-case list. Include the word bridge here if you are receiving data from the Dexcom Share service

SHOW_PLUGINS


Default setting for whether or not these plugins are checked (active) by default not merely enabled. Include plugins here as in the ENABLE line; space-separated and lower-case

TIME_FORMAT



Default setting for new browser views for the time mode. (`12` or `24`)

NIGHT_MODE



Default setting for new browser views for whether Night Mode should be enabled. (`on` or `off`)

BOLUS_RENDER_OVER


U value over which the bolus values are rendered on the chart if the x U and Over option is selected


Dexcom Share

If you want Nightscout to import directly from Dexcom Share

BRIDGE_USER_NAME


Your Dexcom account username to receive CGM data from the Dexcom Share service. Also make sure to include bridge in your ENABLE line.

BRIDGE_PASSWORD


Your Dexcom account password to receive CGM data from the Dexcom Share service. Also make sure to include bridge in your ENABLE line

BRIDGE_SERVER



If you are bridging from the Dexcom Share service and are anywhere *outside* the US change this to EU. (`US` or `EU`)

Alarms

You can customize alarms or leave them to default values

ALARM_TYPES



`simple` and/or `predict`v. Simple alarms trigger when BG crosses the various thresholds set below. Predict alarms use a formula that forecasts where the BG is going based on its trend. You will *not* get warnings when crossing the BG thresholds set below when using the predict type

ALARM_URGENT_HIGH


Urgent High BG threshold triggers the ALARM_URGENT_HIGH alarm. Set in mg/dL or mmol/L as set in DISPLAY_UNITS variable

ALARM_URGENT_LOW


Urgent Low BG threshold triggers the ALARM_URGENT_LOW alarm. Set in mg/dL or mmol/L as set in DISPLAY_UNITS variable

ALARM_HIGH


High BG threshold triggers the ALARM_HIGH alarm. Set in mg/dL or mmol/L as set in DISPLAY_UNITS variable

ALARM_LOW


Low BG threshold triggers the ALARM_LOW alarm. Set in mg/dL or mmol/L as set in DISPLAY_UNITS variable

ALARM_TIMEAGO_URGENT


Default setting for new browser views for the number of minutes since the last CGM reading to trigger an ALARM_TIMEAGO_URGENT alarm

ALARM_TIMEAGO_WARN


Default setting for new browser views for the number of minutes since the last CGM reading to trigger an ALARM_TIMEAGO_WARN alarm

Now click on the Validate button below

If errors show up below, please correct them and click Validate again.

Click the button above.







j) Return to the Railway Raw editor. Paste the result. Click Update Variables.

../../../_images/Railway43.png

Your site will redeploy, wait until redeploy completes.

../../../_images/UpdateNS15.png

  • Leave the Heroku page opened and return to the Railway page.

  • If you cannot log into Heroku, select another deployment option (just above) and reuse your existing Atlas database connection string.


a) Click on Create a New project.

../../../_images/Railway06.png

If you don’t see that, top right, click + New Project.

../../../_images/RailwayDB01.png


b) Select Deploy from GitHub repo.

../../../_images/RailwayM19.png


Select Configure GitHub App.

../../../_images/RailwayM02.png


c) Choose Only select repositories, in the Select repositories drop-down select your own fork of cgm-remote-monitor.
Then, at the bottom, click Install & Authorize.

../../../_images/Railway08.png


You should be back to Deploy from GitHub repo, select it.

../../../_images/RailwayM19.png


d) Now you can select your own GitHub repository.

../../../_images/RailwayM03.png


e) Select Add variables.

../../../_images/RailwayM20.png


f) The Nightscout project will deploy in the background, just ignore it: now we need to import all variables from Heroku.
When you see this, press simultaneously the keys Ctrl and K.
If you use a Mac and K.

../../../_images/RailwayM21.png


g) Select Import variables from Heroku.

../../../_images/RailwayM22.png


h) Click Connect Heroku account.

../../../_images/RailwayM23.png


Click Allow.

../../../_images/RailwayM24.png


i) Redo Ctrl K (or K and select Import variables from Heroku. Now you can select your Nightscout app.

../../../_images/RailwayM25.png


j) Wait until import completes.
Your site will redeploy, wait until redeploy completes.



Congratulations. You created your new Nightscout site with Railway.

Click the site name to open Nightscout.

../../../_images/RailwayM14.png

Recommended

You should change your Railway site name now in order to make it easier to remember. You can also do this later, before setting your uploaders.


New Nightscout Setup


a) Your Nightscout site should open and direct you to a new profile creation.

../../../_images/NewNS50.png

b) Setup your Time zone and eventually all other fields. Do not leave any fields empty. If you don’t know which value to use, just use the default value. You can change these values later at any time.

../../../_images/NewNS44.png

c) Browse down to Authentication status and click Authenticate. Enter your API secret. Click Update.

../../../_images/NewNS45.png

d) Click Save.

../../../_images/NewNS46.png

e) If the following pop-up shows up click OK, and check status (upper right of the window).

../../../_images/NewNS47.png

f) If you need to modify your profile after this, authenticate with the lock icon (top right of the page): enter your API secret. Then click on the hamburger menu and select Profile Editor.

../../../_images/NewNS43.png

Privacy warning

Anyone with access to the URL of your Nightscout site, can view your BG and run reports of your data. It it strongly recommended that you enable security to your site once you’re done with the setup


g) Dexcom Share users should see data flowing in after some minutes. xDrip+ users (including Medtronic CareLink followers) should setup the uploader as shown here. xDrip4iOS users here. AAPS and Loop: consult the relative documentation.

../../../_images/NewNS48.png

You have completed a new Nightscout site creation. You can continue here now.

The following section provides more information that you might not need to use now.





Change your Nightscout site name

Railways automatically makes a name when creating your new site. It is rather difficult to remember.

You can change the site name but need to keep the .up.railway.app domain.

  1. Select your Nightscout app

  2. Go in Settings

  3. In Domains go to the end of line and click the edit icon

  4. Write your new name and check it’s available

    Click Update

    Your Nightscout URL will now be https://yoursitename.up.railway.app

../../../_images/Railway38.png

Change all your uploaders and follower devices to reflect the new URL once verified correct functioning of your Nightscout site.



You have completed a new Nightscout site creation. The following section provides more information for database migration and variables edition that you might not need to use now.



Editing Variables in Railway


Method 1 - Web interface

This is recommended when you only need to edit or add few variables.

a) Open Railway and click login. Login with GitHub.

../../../_images/Railway00.png ../../../_images/Railway01.png

b) Select your Nightscout project.

../../../_images/RailwayM15.png

c) Select your web app.

../../../_images/RailwayM16.png

d) Click on Variables.

../../../_images/RailwayM17.png

e) You can perform various operations on your variables:

  1. Add a new variable with + New Variable

  2. View the variable value with Show Value

  3. Edit or delete the variable or its value with the line end menu

../../../_images/RailwayM18.png

Note that each variable modification will redeploy your project.


Method 2 - Raw Editor

This is recommended when you must perform lots of changes to avoid multiple project redeploys.

a) Open Railway and click login. Login with GitHub.

../../../_images/Railway00.png ../../../_images/Railway01.png

b) Select your Nightscout project.

../../../_images/RailwayM15.png

c) Select your web app.

../../../_images/RailwayM16.png

d) Click on Variables.

../../../_images/RailwayM17.png

e) Click on RAW Editor top right

../../../_images/Railway39.png

f) You can access all your variables in a text editor, each line contains the variable name, the sign = then its corresponding value.

VARIABLE=value

Perform all your changes taking care of uppercase and lowercase information and click Update Variables when finished.

../../../_images/Railway40.png

Once saved your project will redeploy.
If deploy fails, check your modifications…