---
title: Persistent Configuration
slug: litmus-mcp-server/persistent-configuration
docTags: 
createdAt: 2026-05-11T21:39:41.576Z
---

By default, configuration saved through the Web UI (API keys, Litmus Edge instances, model preferences, NATS / InfluxDB / LEM settings) is written to `/app/.env` inside the container. It is lost when the container is removed.

To retain configuration across container restarts and replacements, mount a host file over `/app/.env`.

## One-time setup

```bash
mkdir -p /opt/litmus-mcp
touch /opt/litmus-mcp/.env
```

:::BlockQuote
The host-side file must be created with `touch` **before** running the container. If it does not exist, Docker creates a directory at that path and the application fails to write configuration.
:::

## Run with the volume mount

```bash
docker run -d --name litmus-mcp-server \
  -p 8000:8000 -p 9000:9000 \
  -v /opt/litmus-mcp/.env:/app/.env \
  ghcr.io/litmusautomation/litmus-mcp-server:latest
```

Any configuration you save in the UI is written to `/opt/litmus-mcp/.env` on the host. A new container started with the same `-v` flag picks it up automatically on startup.

## Docker Compose equivalent

```yaml
services:
  litmus-mcp-server:
    image: ghcr.io/litmusautomation/litmus-mcp-server:latest
    ports:
      - "8000:8000"
      - "9000:9000"
    volumes:
      - /opt/litmus-mcp/.env:/app/.env
```

## What gets persisted

The mounted `.env` ends up holding:

- `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, `GEMINI_API_KEY` (whichever you set)
- `PREFERRED_MODEL`, `PREFERRED_MODEL_ID`
- `ACTIVE_EDGE_INSTANCE`, plus `EDGE_INSTANCE_{i}_*` entries for each registered Litmus Edge
- Canonical `EDGE_URL`, `EDGE_API_CLIENT_ID`, `EDGE_API_CLIENT_SECRET` (mirror of the active instance)
- `NATS_SOURCE`, `NATS_PORT`, `NATS_USER`, `NATS_PASSWORD`, `NATS_TLS`
- `INFLUX_HOST`, `INFLUX_PORT`, `INFLUX_DB_NAME`, `INFLUX_USERNAME`, `INFLUX_PASSWORD`
- LEM headers if configured

You can also seed the file before first start by writing values directly. The Web UI will read what is already there.
