> ## Documentation Index
> Fetch the complete documentation index at: https://mage-staging.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Mage environment variables

> Configure Mage settings through environment variables.

## Environment variables in Mage

Environment variables may be set in your Docker container to configure Mage settings. If you’re running Mage using `pip` or `conda`, your local machine’s environment variables
are accessible within the running Mage app.

Environment variables are different from [runtime variables](/getting-started/runtime-variable) or [secrets](/development/variables/secrets).

If you’re running Mage using Docker, you must add the following command line flags:

```bash theme={null}
-e SOME_VARIABLE_NAME_1=secret_value_1 -e SOME_VARIABLE_NAME_2=secret_value_2
```

The command to run Mage using Docker could look like this:

```bash theme={null}
docker run -it -p 6789:6789 -v $(pwd):/home/src \
    -e SOME_VARIABLE_NAME_1=secret_value_1 -e SOME_VARIABLE_NAME_2=secret_value_2 \
    mageai/mageai /app/run_app.sh mage start [project_name]
```

## Setting the prefix for Mage URL

You may need to add a prefix to the Mage url. You can configure the Mage server to start
at a prefix to the url by setting the `MAGE_BASE_PATH` environment variable.

Make sure to set the base path without the leading slash. For example, if you want to start Mage at
`http://localhost:6789/base/url/path`, you would configure your environment
variable like this:

`export MAGE_BASE_PATH=base/url/path`

You can also configure the base path separately for client requests and backend routes by setting
the `MAGE_REQUESTS_BASE_PATH` and `MAGE_ROUTES_BASE_PATH` environment variables respectively.

|                           |                                                                                     |
| ------------------------- | ----------------------------------------------------------------------------------- |
| `MAGE_BASE_PATH`          | Set base path for the entire app.                                                   |
| `MAGE_REQUESTS_BASE_PATH` | Set base path for frontend requests and urls, defaults to value of `MAGE_BASE_PATH` |
| `MAGE_ROUTES_BASE_PATH`   | Set base path for backend routes, defaults to value of `MAGE_BASE_PATH`             |

## Default variables

These are the environment variables used in Mage.

| Variable name                   | Description                                                                                                                                                                                                                   | Example values                                                           |
| ------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
| `ACTIVE_DIRECTORY_DIRECTORY_ID` | Set this value to your organization's tenant id to enable signing in with Microsoft account.                                                                                                                                  | [More info](/production/authentication/microsoft)                        |
| `AUTHENTICATION_MODE`           | Set the authentication mode in Mage. Omitting the variable will default to basic password authentication.                                                                                                                     | `ldap`                                                                   |
| `DEBUG`                         | Turn on "debug" mode. Mage will output more logs that could be useful for debugging issues.                                                                                                                                   | 1                                                                        |
| `DISABLE_NOTEBOOK_EDIT_ACCESS`  | Setting this variable will disable edit access based on the value. [More information](/production/configuring-production-settings/overview#read-only-access)                                                                  | 1                                                                        |
| `DISABLE_TERMINAL`              | Setting this variable will disable access to the terminal.                                                                                                                                                                    | 1                                                                        |
| `ENV`                           | Set the environment of the Mage app. You can use different code or configurations in different environments.                                                                                                                  | `dev`, `staging`, `production`/`prod`                                    |
| `GIT_REPO_LINK`                 | [More information](/production/data-sync/git-sync#git-sync-settings-as-environment-variables)                                                                                                                                 | See link                                                                 |
| `GIT_REPO_PATH`                 | [More information](/production/data-sync/git-sync#git-sync-settings-as-environment-variables)                                                                                                                                 | See link                                                                 |
| `GIT_USERNAME`                  | [More information](/production/data-sync/git-sync#git-sync-settings-as-environment-variables)                                                                                                                                 | See link                                                                 |
| `GIT_EMAIL`                     | [More information](/production/data-sync/git-sync#git-sync-settings-as-environment-variables)                                                                                                                                 | See link                                                                 |
| `GIT_AUTH_TYPE`                 | [More information](/production/data-sync/git-sync#git-sync-settings-as-environment-variables)                                                                                                                                 | See link                                                                 |
| `GIT_BRANCH`                    | [More information](/production/data-sync/git-sync#git-sync-settings-as-environment-variables)                                                                                                                                 | See link                                                                 |
| `GIT_SYNC_ON_PIPELINE_RUN`      | [More information](/production/data-sync/git-sync#git-sync-settings-as-environment-variables)                                                                                                                                 | See link                                                                 |
| `GIT_SYNC_ON_START`             | [More information](/production/data-sync/git-sync#git-sync-settings-as-environment-variables)                                                                                                                                 | See link                                                                 |
| `GIT_SSH_PUBLIC_KEY`            | [More information](/production/data-sync/git-sync#git-sync-settings-as-environment-variables)                                                                                                                                 | See link                                                                 |
| `GIT_SSH_PRIVATE_KEY`           | [More information](/production/data-sync/git-sync#git-sync-settings-as-environment-variables)                                                                                                                                 | See link                                                                 |
| `GIT_ACCESS_TOKEN`              | [More information](/production/data-sync/git-sync#git-sync-settings-as-environment-variables)                                                                                                                                 | See link                                                                 |
| `HIDE_ENV_VAR_VALUES`           | Filter out environment variables in notebook output.                                                                                                                                                                          | 1                                                                        |
| `JWT_SECRET`                    | Modify the json web token secret used for encoding and decoding access tokens. Defaults to `materia`.                                                                                                                         | `your_jwt_secret`                                                        |
| `JWT_DOWNLOAD_SECRET`           | Modify the json web token secret used for encoding and decoding download tokens. Defaults to randomly generated string value. Use an explicit value in horizontally scalable deployments, e.g.: kubernetes, cloud deployments | `your_jwt_secret`                                                        |
| `LDAP_ADMIN_USERNAME`           | [More information](/production/authentication/overview#ldap)                                                                                                                                                                  | See link                                                                 |
| `LDAP_SERVER`                   | [More information](/production/authentication/overview#ldap)                                                                                                                                                                  | See link                                                                 |
| `LDAP_BIND_DN`                  | [More information](/production/authentication/overview#ldap)                                                                                                                                                                  | See link                                                                 |
| `LDAP_BIND_PASSWORD`            | [More information](/production/authentication/overview#ldap)                                                                                                                                                                  | See link                                                                 |
| `LDAP_BASE_DN`                  | [More information](/production/authentication/overview#ldap)                                                                                                                                                                  | See link                                                                 |
| `LDAP_AUTHENTICATION_FILTER`    | [More information](/production/authentication/overview#ldap)                                                                                                                                                                  | See link                                                                 |
| `LDAP_AUTHORIZATION_FILTER`     | [More information](/production/authentication/overview#ldap)                                                                                                                                                                  | See link                                                                 |
| `LDAP_GROUP_FIELD`              | [More information](/production/authentication/overview#ldap)                                                                                                                                                                  | See link                                                                 |
| `LDAP_ROLES_MAPPING`            | [More information](/production/authentication/overview#ldap)                                                                                                                                                                  | See link                                                                 |
| `LDAP_DEFAULT_ACCESS`           | [More information](/production/authentication/overview#ldap)                                                                                                                                                                  | See link                                                                 |
| `MAGE_ACCESS_TOKEN_EXPIRY_TIME` | [More information](/production/authentication/overview#ldap)                                                                                                                                                                  | See link                                                                 |
| `MAGE_BASE_PATH`                | The base path or prefix of the Mage server url. [More information](/getting-started/setup#setting-prefix-for-mage-url)                                                                                                        | `base/path`                                                              |
| `MAGE_REQUESTS_BASE_PATH`       | [More information](/getting-started/setup#setting-prefix-for-mage-url)                                                                                                                                                        | `base/path`                                                              |
| `MAGE_ROUTESBASE_PATH`          | [More information](/getting-started/setup#setting-prefix-for-mage-url)                                                                                                                                                        | `base/path`                                                              |
| `MAGE_CACHE_DIRECTORY`          | The directory Mage uses for storing and retrieving temporary data used in the UI.                                                                                                                                             | `/root/.mage_data/default_repo/.cache`                                   |
| `MAGE_DATABASE_CONNECTION_URL`  | Specify the database connection url for orchestration DB. Defaults to local sqlite db.                                                                                                                                        | [Example](/production/configuring-production-settings/overview#postgres) |
| `MAGE_PUBLIC_HOST`              | The public host url that can be used to access the Mage app. This value will be used in emails or other notifications.                                                                                                        | `http://localhost:6789`                                                  |
| `MAX_PRINT_OUTPUT_LINES`        | The max number of `stdout` lines, such as from `print` statements, included in a message from the websocket server. Defaults to `1000`.                                                                                       | `100`                                                                    |
| `REQUIRE_USER_AUTHENTICATION`   | Enable user authentication in Mage. [More information](/production/authentication/overview)                                                                                                                                   | 1                                                                        |
| `SERVER_VERBOSITY`              | [More information](/development/observability/logging#server-logging)                                                                                                                                                         | See link                                                                 |
| `SHELL_COMMAND`                 | Set shell command to use for the Mage terminal. Default command is `bash` for macOS/Unix and `cmd` for Windows.                                                                                                               | `bash`, `cmd`, ...                                                       |
| `ULIMIT_NO_FILE`                | Override the maximum number of open files allowed in Mage processes.                                                                                                                                                          | 8192                                                                     |
| `USER_CODE_PATH`                | Set this path to be `/home/src/{your_project_name}` so that Mage starts your project and installs the packages in requirements.txt when starting the container.                                                               | `/home/src/mage_project`                                                 |
