Mattermost environment variables: when teams set server options outside the console
Environment variables with the MM_ prefix set Mattermost server options from the process environment, so the same settings can be defined in a container manifest, a systemd unit or a Helm values file instead of being edited by hand in the System Console. If you run Mattermost in containers, under systemd or on Kubernetes with Helm and want configuration kept in version control or a secrets store, this is the mechanism to plan for. Teams usually need it for repeatable deployments where a staging and production server must match, for GitOps workflows where every change is reviewed as a commit, for read-only containers whose root filesystem cannot be written, and for multi-node clusters where every application server should start with identical options. A single small server managed by one administrator rarely needs it. Editing settings in the console and keeping a backup of the configuration file is simpler there, and the overhead of maintaining variable files is not repaid.
Before you write any variable, confirm the exact names and their availability in the configuration reference for the server release you run. Variable names follow the structure of config.json, and some options are added, renamed or removed between releases, so a value that works on one version may be ignored on another. Plan to test the manifest against a non-production instance on the same release, then record the release number alongside the variable file. Expect that a setting supplied by an environment variable will be locked in the System Console, so administrators who try to change it there will find the control unavailable. Decide up front which team owns each value, and where secrets such as database credentials and SMTP passwords will come from, so the lock does not surprise the people who manage day-to-day settings.
Setting MM_ variables in containers, systemd and Helm
In a container deployment, Mattermost reads MM_ variables from the environment of the running container, so the setting is supplied when the container starts rather than edited inside the image. You can pass them one at a time on the run command or load a group of them from an env file. Plan the variable list before go-live, because every value you supply becomes the source of truth for that setting.
- Run-time flags: Pass a single variable with
-eon the run command. Good for a short list and quick tests. - Env file: Load many variables with
--env-file. Keep the file outside the code repository and note the names of the keys in your change record. - Secrets: Database passwords and other credentials should come from your secrets mechanism, such as an orchestrator secret store or a vault, and be injected at start. Do not commit a plain env file that contains them.
- Naming: Confirm each key against the server version you run, since option names change between releases.
- Restart: Recreate the container after changing a variable, because the environment is read at start.
To verify, start the container and open the System Console for a variable you set. A setting supplied by the environment appears as managed and cannot be changed in the console. You can also search the server log at startup for the configuration load entry.
On a Linux host running Mattermost as a systemd service, the cleanest place for environment variables is a drop-in override for the unit, not the packaged unit file, so package upgrades do not overwrite your settings. You can add values inline with an Environment entry or point to a file with EnvironmentFile. The file approach keeps secrets out of the unit definition and out of process listings.
- Override file: Create a drop-in with
systemctl edit mattermostso the change is stored in a separate override file. - Inline entries: Use
Environmentfor non-sensitive values that are easy to review in the unit. - EnvironmentFile: Reference a file for database credentials and other secrets. Set owner to the service account or root, and mode to a restricted value such as
600, so other local users cannot read it. - Reload: Run
systemctl daemon-reloadafter any change to units or drop-ins, then restart the service. - Audit: Keep the override and env file under version control in a private repository, without the secret values.
To verify, restart the service and check the server log for the configuration load at startup. Then open the System Console and confirm that the variable you set shows as managed. If the setting still looks editable, the variable was not read, so check the unit name, the file path and the reload step.
On Kubernetes, Helm charts normally expose settings as values in a values file. The chart renders those values into the pod's environment or into a configuration source, so you usually set the value key and let the chart produce the MM_ variable. Treat the chart's value keys as version-specific: confirm them against the chart version you install and record that version in your change record.
- Values files: Keep one values file per environment, such as test and production, and apply it with
helm upgrade --install. - Key mapping: Read the chart's values reference to see which keys become environment variables. Some options may be exposed only through an extra value or a generic environment map.
- Secrets: Reference existing Kubernetes Secrets for passwords and keys instead of writing them into values files. Confirm how the chart expects the secret name and key to be specified.
- Rollout: Changes to environment values trigger a new rollout of the pods, so schedule them and check the rollout status.
- Review: Run
helm templateor a diff tool on the rendered output before applying, to confirm the expected variables appear.
To verify, inspect the running pod's environment or the rendered manifest, then open the System Console and confirm that the setting is shown as managed. A value that appears in the chart but not in the pod means the key path is wrong for that chart version.
Which Mattermost settings to set as variables and which to leave in the console
This table sorts common Mattermost setting groups by why you would set them as environment variables, what goes wrong if they live only in the System Console, and what to confirm for your version. Read each row by asking who must change the value, how often it changes, and whether every node in the deployment must receive the same value.
| Setting group | Typical reason to use a variable | Risk if managed only in the console | What to confirm |
|---|---|---|---|
| Database connection and secrets | Credentials stay out of the admin UI and version-controlled files, and every container or node starts with the same connection | Changes are not reproducible during a rebuild, and credentials may be exposed to anyone with console access | Which secrets your orchestrator injects, and whether the database settings are read from the file or the environment in your version |
| File storage backend credentials | Access keys or managed identities are supplied by the platform, and rotation happens in the secret store | Keys entered in the console can drift between nodes and are hard to rotate without a service interruption | The storage backend options your version supports and how credentials are rotated on each node |
| SAML or OIDC identity provider settings | Identity provider endpoints and certificates must match on every node and change only when the identity team changes them | Mismatched settings across nodes cause login failures that look intermittent, and certificate changes are easy to miss | Whether certificates are distributed by file, environment or database, and the plan's SSO entitlement |
| SMTP and email | Mail relay hosts and sender addresses are fixed by the infrastructure team and need to survive container restarts | Notification and password reset email can silently stop after a rebuild that restores an old console value | The relay hostname, authentication method and sender address that operations will verify after each change |
| Site URL and TLS-related values | The public address must match the reverse proxy and certificate on every node, and it is set once per environment | An incorrect site URL breaks links, websocket connections and identity provider callbacks | The public hostname, the proxy listener and whether TLS terminates on the proxy or the server |
| Plugin settings (JSON values) | Structured plugin configuration is easier to review, test and version as a single value than as form fields | Nested JSON edited in the console is hard to diff, and a mistake can disable a plugin without a clear audit trail | How each plugin reads its settings, which keys are locked after the variable is set, and how to validate JSON before deployment |
| Rate limits and feature flags | Limits and flags are tuned per environment, such as stricter settings in production than in a test cluster | Staging and production can drift apart, and a console change may be lost during a redeployment | Which limits and flags your version exposes as variables and which remain editable in the console |
| Cosmetic or team-level settings | Rarely needed, so the console is the right place for branding, announcements and team-specific defaults | Low risk, but locking these in variables slows routine changes by administrators who own them | Who owns the change, and whether the value must match across nodes or can differ per team |
How a setting moves from the environment into the running server
The path starts with the deployment platform, whether a container runtime, a systemd unit or a Helm release, which supplies MM_ variables to the Mattermost process. The server reads config.json, then applies any matching environment variable on top of that value, and the effective configuration is loaded into memory. Settings set this way appear as locked in the System Console, while a setting with no matching variable stays editable there. This is the general order only, so confirm the exact precedence and locking behavior against the Mattermost release you run before relying on it.
The general startup order for settings, to be confirmed against your release.
Setting up Mattermost environment variables in a repeatable way
This sequence moves Mattermost settings out of manual console changes and into variables that every node, container or Helm release applies the same way, with a read-back and a rollback path at each stage. The result is a configuration you can review, reproduce in a test environment and audit against the running servers.
Inventory settings to manage as code
Work with the platform owner and the security team to list every setting that must match across environments or nodes, such as site URL, database connection, file storage, SMTP, authentication and plugin options. Mark the settings that administrators may still change in the System Console, because setting a variable locks that field in the console. Finish with a written list that names the owner of each setting. The step is done when every setting is marked either as code or as console-managed, and no field is left undecided.
Choose the secret source for credentials
Decide where database passwords, S3 keys, SMTP credentials and SAML or LDAP secrets will come from before any variable is written. Options include your container orchestrator's secret objects, a systemd credential or environment file with restricted permissions, or your organization's secrets manager. Confirm that no secret is stored in a Helm values file, a Git repository or a shell history. The step closes when the team can name the source for each credential and who can read it.
Define variable names for the exact server version
Use the configuration reference that matches the Mattermost server version you will run, and map each managed setting to its MM_ variable name. Confirm the naming rules for nested keys and the JSON format required for plugin settings, since these differ from flat values. Record the version in the change record, because option names can change between releases and an upgrade may require a new mapping. The step is done when every managed setting has a variable name, a value type and a documented source, checked against the reference for that version.
Apply variables in a test environment
Build a test environment from the same image, container tag or package that production will use, then apply the variables through the same mechanism you plan to use in production, whether that is a container spec, a systemd unit override or Helm values. Start the server and confirm that it reads the variables and that the database and file storage connect. Note any setting that the server ignores or rejects, and correct the name or format before moving on. The step is done when the test server starts cleanly with every managed variable present.
Verify with a read-back and functional tests
Compare the effective configuration on each node or pod with the expected values, using the server's configuration output or the System Console where a value is shown read-only. Then run a login test through the identity provider you configured and send a test message with an attachment, to confirm that storage, authentication and notifications work. Check that the System Console shows the managed fields as locked. The step closes when the read-back matches on every node, the login and message tests pass, and the locked fields appear as expected.
Roll out to production with a documented rollback
Schedule the change in your normal window, and keep the previous variable set and image tag ready so you can restore them without rebuilding. Apply the variables to production one node or pod group at a time, repeating the read-back after each group so that every node stays on one configuration. Record the rollback trigger, such as a failed login test or a node that reports a different effective value. The step is done when all nodes show the same effective settings, the change record holds the approved variable set, and the rollback steps have been written and tested in the test environment.
What the System Console lock means for admins and change control
When a setting is supplied by an MM_ environment variable, the System Console shows that setting as managed and does not let administrators change it there. The variable becomes the single source of truth for that option, so any console edit to a locked setting will not persist. Before go-live, the team should export a list of every locked setting in its environment, because the console alone will not tell a new administrator which values came from the container, unit file or Helm values. Confirm the exact lock behavior for each setting in the Mattermost release you run, since coverage can differ between settings and versions.
The operational consequences fall on people who do not read deployment files. A support engineer who changes a notification or file setting in the console may see it revert or appear to do nothing, and an administrator may assume the product is faulty. Plan for a change path that runs through the variable definition: edit the value in the container spec, systemd override or Helm values, then restart or redeploy the Mattermost process so the new value loads. Ask who will run that restart, in which window, and whether it needs an approval step, because a console-only change that ships on a Friday afternoon will not behave the way the console suggests.
Write down three things and keep them current. First, the register of locked settings, with the variable name, the environment it applies to and the reason it is locked. Second, a named owner for each variable definition, usually the platform team that owns the deployment repository, with a separate approver for security-relevant settings such as authentication and file storage. Third, a communication rule covering who is told about a change, through which channel, and how the team will document rollbacks. Store the register beside the deployment code so that reviews of the code and reviews of the configuration happen in the same place.
Keeping secrets and admin access safe when settings live in variables
Environment variables are convenient for Mattermost configuration, but they also spread sensitive values across shells, process tables, unit files and pipelines. The cards below cover the places where a database password, storage key or SMTP credential can leak, and the controls that keep those values contained through routine changes and rotation.
Keep credentials out of plain files and history
Database passwords, S3 or Azure storage keys and SMTP credentials should reach the Mattermost process from a secret store or an encrypted source, not from a typed export line or a plain text env file copied between hosts. Shell history keeps every command typed interactively, so avoid inline assignments with real values. Check that no environment file has permissions wider than the service account needs, and that backups of configuration directories do not carry unencrypted copies of these values.
Restrict who can read the process environment
Anyone who can read the environment of the running Mattermost process, its systemd unit or its Helm release can read every MM_ value set there. Limit read access on unit files and environment files to root and the service account, and limit Kubernetes access to the release's Secrets and ConfigMaps through RBAC. Confirm that administrators who can exec into pods or run systemctl show are the same people authorized to hold database and storage credentials.
Keep definitions in version control without secrets
Version control is the right place for variable names, non-sensitive values, chart values and deployment templates, so every change to Mattermost settings is reviewable. Secret values should be referenced by name and injected at deploy time. Scan commits and pull requests for credential patterns before merge, and check that the repository history does not already contain a value that was committed by mistake, since deleting it from the latest commit does not remove it from history.
Audit variable changes through the pipeline
When variables change through a pipeline, the pipeline log, the merged change and the deployment record become the audit trail for who changed a database host, a storage endpoint or an SMTP relay. Require that changes to authentication or storage variables pass review by someone other than the author. Ask your team which pipeline system keeps deployment logs, how long they are retained, and whether those logs mask secret values or print them in plain text.
Prevent leaks through process and container output
Values passed as command arguments or set in a container definition can appear in process listings, docker inspect output and orchestrator describe commands to anyone with access to the host or API. Check which of your tools display environment values by default, and restrict access to those commands. Where possible, pass sensitive values through files mounted with restricted permissions or through orchestrator secret references, and verify with a test that the value does not show in a standard inspection.
Rotate credentials without stale copies
Rotating a database or storage credential means changing it in the secret store, restarting or rolling the Mattermost processes, and then confirming that no older value remains. Because a MM_ variable overrides config.json, a stale value in the file can be hidden while the variable is set and reappear if the variable is removed. Check that the System Console no longer offers the old value, and record the rotation date and the nodes that picked up the change.
Questions teams ask before setting Mattermost options as environment variables
How much effort does moving Mattermost settings into environment variables take?
The effort depends on how many settings you move, how many environments share them, and how your team deploys. A single server with a handful of settings in one environment is a small change. Effort grows with the number of settings, the number of environments such as development, test and production, and whether changes flow through GitOps or Helm values that need review. Each cluster node that shares one configuration adds checks, because every node must read the same values. Ask any partner to break the quote into inventory of current settings, mapping to MM_ names, secret handling, environment rollout and validation, so you can see which part drives the cost.
Can one administrator make this change without outside help?
Yes, a single administrator with access to the deployment platform can make the change, provided they understand which settings the server reads from config.json and which the System Console controls. The main risk is not the syntax but the lock: once a setting is supplied by an environment variable, the System Console no longer lets you change it, so a mistake can be hard to see and fix from the admin UI. Solo administrators should keep a record of every variable they set, test the change in a non-production environment first, and have a second person review the list before production rollout.
What does the work need from our team?
Plan for four things before work starts. First, access to the platform that runs Mattermost, such as the container runtime, systemd host, or Kubernetes cluster with permission to edit deployment manifests or Helm values. Second, a secrets store for database passwords, SMTP credentials and SAML or LDAP secrets, so they are not stored in plain manifests. Third, a test environment that matches production closely enough to catch naming and precedence mistakes. Fourth, a named owner for each variable who approves changes and knows what the setting controls. Without an owner, values drift between environments and nobody knows which copy is correct.
How long does validation take, and what makes it longer?
Validation time depends on how many settings change behavior that users see, such as sign-in, file storage, email and integrations, and how many environments must be tested. Each change should be checked in the running server, not only in the file, because a misspelled MM_ name is silently ignored in many cases. Validation runs longer when the team must test SSO flows, JSON-based plugin settings, or cluster behavior across several nodes. Ask for the validation steps in the quote and confirm which ones your team will run and which the partner will run.
Do environment variables survive a Mattermost upgrade, and what should we check afterward?
Environment variables are set outside the Mattermost binary, so an upgrade does not remove them, but a new version can change the names, defaults or accepted formats of a setting. After each upgrade, compare the running configuration with your variable list, confirm that the server starts without configuration warnings in its logs, and test sign-in, email, file upload and any plugin that reads JSON settings. Check the release notes for each version you pass through, and plan these checks into your Mattermost server releases calendar so they happen before an Extended Support Release ends.
When should we store Mattermost configuration in the database instead?
Consider moving configuration into the database when several nodes must share one configuration without maintaining identical variable sets, or when you run read-only containers and want settings to live in one place. A high availability cluster is the usual reason, because every application node has to agree on settings. Also consider it when the number of environment variables becomes hard to review or when configuration changes need to be made by administrators through the System Console. Before moving, confirm your plan supports the feature and that you have a tested migration path for the current settings.
Is it safe to put passwords and certificates into environment variables?
It is safer than storing them in a configuration file in source control, but it is not safe by default. Environment variables can appear in process listings, container inspection output, crash dumps and deployment logs, so restrict who can read them. Use your platform's secrets mechanism, such as a Kubernetes Secret with encryption at rest or a secrets manager that injects values at start, and rotate credentials through that store. Avoid writing secret values into shell history or tickets. Confirm the exact handling of each secret with your security team before production.
Limits to confirm for your Mattermost version and environment
Environment variables are a convenient way to manage Mattermost settings, but they carry version-specific rules and trade-offs. The cards below list what to confirm with the vendor documentation for your exact server version before you build your configuration process around them.
Variable names and formats by version
Each MM_ variable maps to a configuration key, and the naming rules and value formats can change between server releases. Confirm the exact variable name, data type and accepted values for the version you run, since a misspelled or unrecognized variable may be ignored without an obvious error. Record the version next to your variable list so the next upgrade review has a reference point.
Settings that cannot come from variables
Not every configuration option can be supplied through an environment variable, and some settings need a database or console workflow instead. Build an inventory of the settings you plan to control, then confirm each one is supported as a variable in your version. Settings you cannot set this way still need a documented manual step in your change process.
Plugin JSON settings across upgrades
Plugin settings passed as JSON inside a variable are harder to read, validate and diff than plain keys, and their structure can depend on the plugin version. Confirm how each plugin reads its settings after an upgrade, and whether a plugin update resets or ignores values set by variables. Test this in a staging environment before any production upgrade.
Settings on every high availability node
In a multi-node cluster, each application server must read a consistent configuration, or nodes can behave differently. Check the high availability cluster documentation to confirm whether variables must be set identically on every node, and how cluster-wide settings are shared. Treat any mismatch between nodes as a defect to fix before go-live.
HA cluster docsHelm chart value coverage
If you deploy on Kubernetes, the Helm chart must expose the values you need, or you will fall back to patching manifests by hand. Compare the chart's documented values against your variable list for the chart version you pin. Confirm how the chart renders secrets into the pod, because a value passed in plain text in a values file can end up in version control.
Compliance acceptance of environment control
Your security and compliance teams must accept that some settings are controlled through the deployment environment rather than the System Console. Ask them whether they require changes to be recorded, approved and reviewed in a specific system, and whether environment-based changes meet that standard. Document who can change variables, where the values are stored and how drift is detected.
How DeployOpen scopes and delivers Mattermost configuration work
DeployOpen plans Mattermost configuration as code before anything is changed on a server, container or Helm release. Each engagement is fixed-scope, with the variables, deployment targets and handover agreed in writing before work starts.
How we scope
- Inventory every setting currently in config.json and decide which ones move to MM_ variables.
- Map each deployment target, including containers, systemd units and Helm values, that will read the variables.
- Agree in writing which settings stay in the System Console and which are locked by environment variables.
How we build
- Write environment files, unit overrides and Helm values with MM_ names checked against the running server version.
- Encode JSON-valued plugin settings in a repeatable form and test that each one loads as expected.
- Confirm precedence over config.json on a staging instance before any change reaches production.
How we hand over
- Deliver a variable register listing each name, its source, its owner and the System Console areas it locks.
- Document the procedure for changing a locked setting, including which file or chart value to edit and restart steps.
- Walk your administrators through the register and the rollback steps, and record open questions for your team to confirm.
How we support
- Offer ongoing support as a retainer to review variable changes before each Mattermost server upgrade.
- Retest locked settings after version changes so that configuration drift is caught early.
- Keep the variable register current as your deployment, identity provider and storage settings change over time.

