The official NightScout site has been updated with good documentation on Connection String issues, you can now use that page as a companion to this one.

This is still the better page if you like printed step by step numbered directions.

If you messed up your Atlas db string for NightScout, here is how you make a new one.

Note, if you migrated, or set up NightScout and had it working on Atlas, this is probably not the fix you are looking for. This is only if you messed up the connection string and don’t have the correct username/password combo to put it back together.

  1. Sign into your Atlas account.
  2. Click the drop-down arrow next to your account name in the top right.
  3. Scroll down to “Organizations” from the drop-down menu.
  4. You should only have one organization, if you have more than one, pick the one that goes to your Nightscout site. Click your Organization Name.
  5. You should only have one project, click the Project Name.
  6. You should be at the Clusters screen, there should be a blue oval with the word “SANDBOX” on the screen.  We will come back here, for now, go to “Database Access” below Security on the menu on the left.
  7. You need to create a new User Name by clicking the big green button “Add New Database User“.  You should call your new User Name “nsdbuser”. If you already have a “nsdbuser”, click “DELETE” on the far right and follow the prompts to remove the user.

Authentication Method Password.

User Name (first box) nsdbuser (all lower case).

Password (second box) enter an EXACTLY a 12 character password containing only numbers and lower case letters such as “pizza4uandme“.

  1. Change the Database User Privileges to “Atlas Admin“.
  2. Make no other changes to this screen, click the green “Add User” button.
  3. You should be back at the Database Access screen and you should see your new user.
  4. Click on “Clusters” tab on the far left under DATA STORAGE.
  5. Click the grey “COLLECTIONS” box.
  6. You should see the name of your database, it will be something like “nightscout.activity” or if you migrated it could be some gibberish like “heroku_bqxhd9zz.activity”. Whatever it is, write it down or copy it to a scratchpad the part BEFORE THE “.activity” it is your database name, which you will enter into the connection string in a bit.
  7. Click on “Clusters” tab again.
  8. Click the grey “CONNECT” button.
  9. Click the middle “Connect your application” box
  10. Click “Copy” to get a copy of the string.
  11. Click “Close“.
  12. Open some kind of a scratch pad such as a Google Doc, Notepad, Wordpad, Textedit.
  13. Paste into the scratchpad (left click, paste).
  14. You should end up with a string that looks like this:


  1. Check that the username is correct, if not, change it.
  2. Replace the password with your 12 character password
  3. Replace the dbname with your database name

Your string should look like this:


This string will be used as your MONGO_CONNECTION variable in Heroku.

If you are making a new Nightscout site, the build procedure might make you put this string into MONGO_URI or something similar. After the build is complete, go back into ConfigVars and delete this entry and instead add the MONGO_CONNECTION variable and put the string in there.


Support for NightScout (If you are still stuck) is in the FaceBook group CGM in the Cloud


Comments, corrections, complaints about this document can be sent via the feedback link below, it is only for comments about the document, no support will be given via the feedback page.

Skip to content