# Nightscout in Northflank
```{admonition} Too complicated? Not what you're looking for?
:class: seealso
Consider a hosted Nightscout service! Check for easier solutions [here](/index.md#nightscout-as-a-service).
```
```{card}
## Northflank

^^^
You can create your new Northflank Nightscout site with a [MongoDB Atlas](/vendors/mongodb/atlas) database or with its own [Northflank database](/vendors/northflank/database).
**Pros**:
* Nightscout fits in the free tier
* Easy to deploy or migrate an existing site from Heroku
* Simple to use and troubleshoot
* Can use a native Northflank MongoDB database
* You can deploy up to $20/mo worth of free resources on Northflank’s managed cloud
**Cons**:
* Northflank might throttle free sites when paid users need resources
* The Nightscout address generated for your site is virtually impossible to remember
```
## Set up a new Nightscout
### Create your Northflank 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](/nightscout/database) before starting your Nightscout web app creation with Northflank.
Come back here when you have a MONGODB_URI connection string.
```
```{admonition} Migrating?
:class: tip
Copy the connection string from your previous platform: [edit the variables](/nightscout/setup_variables.md#nightscout-configuration) and look for `MONGODB_URI`.
If you don't see `MONGODB_URI` but see `MONGO_CONNECTION` (**NOT** `MONGO_COLLECTION`): use its value.
```
### Step 1: Create a GitHub account and fork the Nightscout project
```{tab-set}
:::{tab-item} This is not necessary anymore (with a Docker image)
Continue with Step 2.
:::
:::{tab-item} I don't have a GitHub Account
### Create a GitHub account
::: {include} /vendors/github/create.md
:::
:::{tab-item} I already have a GitHub Account
### Update your Nightscout fork
:::{include} /vendors/github/update_b.md
:::
```
### Step 2: Create a Northflank account
***If you already created your database in Northflank, skip to step 3.***
a) Sign-up to [Northflank](https://app.northflank.com/signup) in a new browser tab. Login with GitHub (click on the logo).
b) Confirm your GitHub account if required.
c) Select `Only select repositories`, in the drop-down list select `cgm-remote-monitor` then click `Install & Authorize`.
c) Enter a user name, your email address and invent a password (type it twice to confirm). Accept the TOS and Privacy Policy then click `Continue `.
d) Click `Choose theme`.
e) Select `Skip for now`.
f) Select `Create free project`.
g) Enter a project name (for example nightscout) and select a region (you can make it geographically close to where you live) then click `Create project`.
### Step 3: Deploy Nightscout in Northflank
**What are you trying to do now?**
```{tab-set}
:::{tab-item} I want to create a brand new Nightscout from a Docker image (recommended)
:::{include} new_user_d.md
:::
:::{tab-item} I want to create a brand new Nightscout (old method)
:::{include} new_user_a.md
:::
:::{tab-item} I want to migrate from Heroku
:::{include} migrate_a.md
:::
```
To open your Nightscout site, navigate to your project `Services` and click the address link top right.
**Good time to check you selected the right plan.**
Make sure you selected the developer sandbox plan to avoid unexpected fees.
```{include} /nightscout/first_setup.md
```
## Change your Northflank Nightscout site name
You [cannot](https://northflank.com/docs/v1/application/network/configure-ports#public-ports) override the default name if you don't have a DNS.
You can use [TinyURL](https://tinyurl.com/) to get a shorter name.
You can also use a free [dynamic DNS](/nightscout/dns) service to do this in order to have something easier to remember.
Keep the original Northflank URL in your [uploaders](/uploader/setup/) and [followers](/nightscout/downloaders/).
------
You have completed a new Nightscout site creation. The following section provides more information for variables edition that you might not need to use now.
------
## Editing Variables in Northflank
a) Open [Northflank](https://app.northflank.com/login) and login with your username or with GitHub.
b) Select `Services ` then your Nightscout project.
c) Select `Environment` then `Edit`.
e) You can perform various operations on your variables:
1. Add a new variable with `+ Add Variable`
2. Edit variables values directly in the table
3. Delete a variable with the bin icon
~~~{note}
Multiple lines values should have a `\n` separating each original line.
Example:
Once the full string copied in the variable, switch to JSON mode and replace **all spaces** with `\n`.
*Note: This will only show correctly in JSON view.*
~~~
Don't forget to `Update & restart` when you're done editing.
## Copy all variables from Heroku
a) Export all your Heroku variables as explained [here](/troubleshoot/heroku.md/#method-2-export). In a file you can call `heroku.env`.
If you're currently deploying a new Northflank Nightscout site, select `Env`.
Continue to **c)** below.
b) If you want to modify an existing Northflank site,
Open [Northflank](https://app.northflank.com/login) and login with your username or with GitHub.
Select `Services ` then your Nightscout project.
Select `Environment` then `Env`.
c) Select `Import from file` then the file (`heroku.env`) you saved in **a)**.
Your variables should display like this:
d) If you're creating a new site, return to the step you were following before importing all variables from Heroku.
e) If you were importing all variables from a running Northflank Nightscout site, select `Update & restart`.
