# Nightscout in Fly.io
```{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}
## Fly.io
![Fly.io](/vendors/img/Fly.io.png)
^^^
You can create your new Nightscout site in Fly.io.
**Pros**:
* Nightscout fits in the free tier
**Cons**:
* **Maintaining your site requires the use of command line instructions, not very intuitive**
* Fly.io stores variables as secrets: you cannot read them
* Relying on the MongoDB Atlas database
```
## Step 0: Create a database
```{tab-set}
:::{tab-item} I don't have a database yet
Make sure you [create one](/nightscout/database) before starting your Nightscout web app creation with Fly.io.
Come back here when you have a `MONGODB_URI` connection string.
:::
:::{tab-item} I already have a database
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 fly.io account
[Sign up](https://fly.io/app/sign-up) to Fly.io.
You will need to add credit card information to get Nightscout running.
Whenever requested, add one to prove you're a real person:
Nightscout should run for free within the [allowances](https://fly.io/docs/about/pricing/#free-allowances). If you get billed, please report costs [here](https://github.com/nightscout/nightscout.github.io/issues/new) to have the documentation updated.
## Step 2: Install `flyctl`
```{warning}
The web terminal feature was removed from Fly.io.
You need a computer with flyctl.
```
Follow [these instructions](https://fly.io/docs/hands-on/install-flyctl/) to install `flyctl` on your computer.
*Note for Windows: you might experience issues with Git Bash or PowerShell, try an elevated command prompt.*
## Step 3: Prepare the Nightscout project
Type (or copy and paste) the following command in the terminal:
a) Authenticate in Fly.io:
`flyctl auth login`
Clone the official Nightscout repository:
`git clone https://github.com/nightscout/cgm-remote-monitor`
b) Navigate to the Nightscout code directory copied locally with:
`cd cgm-remote-monitor`
c) Deploy your site with Fly.io.
`flyctl launch`
To the question `Would you like to tweak these setting before proceeding?` answer `Y` (yes).
A web page to your new project will open in Fly.io.
d) Type your new Nightscout site name, make sure it is valid and isn't already used by someone else.
e) Select the region closest to where you live, but make sure it doesn't require a paid plan.
f) In services set the port to `1337`.
g) Make sure to select a `shared CPU 1x` with only `256MB` of memory to remain within the [free allowances](https://fly.io/docs/about/pricing/#free-allowances) limits.
h) Don't select any database and `Confirm Settings`.
i) Deployment will start. Wait until it completes.
## Step 5: Set your Nightscout secrets
a) 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.
### **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](https://nightscout.github.io/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**