# Configuration reference

> Every Neurouter environment variable with its default and what it does, from PUBLIC_URL and DATABASE_URL to OIDC, OAuth, embeddings, egress policy and telemetry.

Source: https://neurouter.com/docs/configuration · Last updated: 2026-11-24

Neurouter is configured with environment variables, validated at start-up. An invalid value stops the server with a message naming the variable. In development the server also loads a `.env` file; in production it reads the real environment. Gateway behaviour that admins change at runtime (approval timeouts, rate-limit defaults, retention, audit export) lives in *Settings → Gateway settings* instead; see [Runtime settings](#runtime-settings) below.

Defaults below are the server's built-in defaults. The repository's `.env.example` sets some values differently for local development.

## Production requirements

With `NODE_ENV=production` the server refuses to start unless:

- `PUBLIC_URL` is set, starts with `https://` and has no trailing slash;
- `NEUROUTER_MASTER_KEYS`, `NEUROUTER_ACTIVE_KEY_ID` and `HASH_PEPPER` are set;
- `OIDC_ISSUER`, `OIDC_CLIENT_ID` and `OIDC_CLIENT_SECRET` are all set.

`AUTH_DEV_LOGIN=true` is refused unless `NODE_ENV=development`. Outside production, missing keys fall back to ephemeral values with a warning, so the server boots with no `.env`.

## Core

| Variable | Default | Description |
|---|---|---|
| `NODE_ENV` | `development` | `development`, `test` or `production`. |
| `HOST` | `0.0.0.0` | Listen address. |
| `PORT` | `3000` | Listen port. |
| `PUBLIC_URL` | `http://localhost:PORT` outside production | External origin users and clients use, e.g. `https://mcp.example.com`. The MCP resource is `PUBLIC_URL/mcp`; OIDC and OAuth redirect URIs and cookies are built from it. |
| `TRUST_PROXY` | `loopback` | Which reverse proxies to trust for client IP and protocol. |
| `INSTANCE_ID` | — | Optional replica identifier (also used in telemetry). |
| `LOG_LEVEL` | `info` | `fatal`, `error`, `warn`, `info`, `debug`, `trace` or `silent`. |
| `LOG_PRETTY` | `false` | Human-readable logs instead of JSON. |
| `ORG_NAME` | `Neurouter` | Organization name shown in the UI. |

## Database

| Variable | Default | Description |
|---|---|---|
| `DATABASE_URL` | `sqlite:./data/neurouter.db` | `sqlite:` path for local evaluation, or `postgres://…` (PostgreSQL 16+ with pgvector) for production and for more than one replica. |
| `AUDIT_DATABASE_URL` | same as `DATABASE_URL` | Optional separate database for the audit log, sessions and metric rollups. |
| `AUDIT_ARCHIVE_URL` | — | Where audit rows are archived before retention deletes them: `file:`, `s3://`, `gs://` or `azblob://`. |
| `DB_POOL_MAX` | `20` | Main database pool size. |
| `AUDIT_DB_POOL_MAX` | `10` | Audit database pool size. |
| `MIGRATE_ON_START` | `true` | Apply migrations when the server starts. The Helm chart can run them as a Job instead. |

## Encryption keys

| Variable | Default | Description |
|---|---|---|
| `NEUROUTER_MASTER_KEYS` | — (required in production) | Key-encryption keys as `id:base64` pairs, comma-separated, for example `k1:…,k2:…`. Each must decode to 32 bytes; ids are 1–32 characters of letters, digits, `_` or `-`. |
| `NEUROUTER_ACTIVE_KEY_ID` | — (required in production) | Which key wraps new data keys. Must be one of the ids above. |
| `HASH_PEPPER` | — (required in production) | HMAC pepper for API keys and OAuth tokens, at least 32 characters. Changing it invalidates every API key and token. |

Generate all three with `npm run keys -- gen`. See [Deployment](https://neurouter.com/docs/deployment#keys-and-rotation) for rotation.

## Human sign-in (OIDC)

| Variable | Default | Description |
|---|---|---|
| `OIDC_ISSUER` | — | Issuer URL of your identity provider. Set together with the next two. |
| `OIDC_CLIENT_ID` | — | Client ID registered at the provider. |
| `OIDC_CLIENT_SECRET` | — | Client secret. |
| `OIDC_DISPLAY_NAME` | `Single sign-on` | Label on the sign-in button. |
| `OIDC_SCOPES` | `openid email profile` | Scopes requested at sign-in. |
| `OIDC_GROUPS_CLAIM` | `groups` | ID-token claim that carries group names or IDs. |
| `OIDC_ADMIN_GROUPS` | — | Comma-separated group values that grant the Admin role. |
| `OIDC_AUDITOR_GROUPS` | — | Comma-separated group values that grant the Auditor role. |
| `OIDC_ALLOWED_EMAIL_DOMAINS` | — (any) | Comma-separated email domains allowed to sign in. |
| `OIDC_GROUP_AUTO_CREATE` | `false` | Create a Neurouter group for every value in the groups claim. |
| `BOOTSTRAP_ADMIN_EMAIL` | — | Pre-provisions this email as an admin, so the first sign-in has admin rights. |
| `AUTH_DEV_LOGIN` | `false` | Email-only login without an identity provider. Development only. |
| `SESSION_TTL_HOURS` | `12` | Maximum length of a browser session. |
| `SESSION_IDLE_MINUTES` | `120` | Idle timeout of a browser session. |

The redirect URI to register at your provider is `PUBLIC_URL/api/auth/callback`. Provider-specific steps: [identity provider guides](https://neurouter.com/integrations).

## MCP endpoint and OAuth

| Variable | Default | Description |
|---|---|---|
| `MCP_ALLOWED_ORIGINS` | — | Extra browser origins allowed to call `/mcp`, in addition to `PUBLIC_URL`. |
| `OAUTH_ACCESS_TOKEN_TTL_SEC` | `3600` | Lifetime of access tokens issued to MCP clients. |
| `OAUTH_REFRESH_TOKEN_TTL_DAYS` | `30` | Lifetime of refresh tokens. |
| `COORDINATION_BACKEND` | `auto` | `auto`, `memory` or `postgres`. How replicas share rate limits, approvals and caches. |

## Tool search embeddings

| Variable | Default | Description |
|---|---|---|
| `EMBEDDINGS_ENABLED` | `true` | Use vector search in addition to keyword search. |
| `EMBEDDINGS_MODEL` | `onnx-community/granite-embedding-small-english-r2-ONNX` | Local embedding model. |
| `EMBEDDINGS_DTYPE` | `q8` | `fp32`, `fp16`, `q8` or `q4`. |
| `EMBEDDINGS_DIMS` | `384` | Embedding dimensions. |
| `MODELS_DIR` | `./models` | Where models are cached. |
| `EMBEDDINGS_ALLOW_REMOTE` | `true` | Allow downloading the model. The container image bakes the model in and sets this to `false`, so it needs no network access for models. |

## Outbound network policy

| Variable | Default | Description |
|---|---|---|
| `UPSTREAM_ALLOW_PRIVATE_NETWORKS` | `true` | Allow upstream MCP servers on private networks. |
| `UPSTREAM_DENY_CIDRS` | `169.254.0.0/16,fd00:ec2::/32` | Address ranges upstream calls may never reach (cloud metadata by default). |
| `OUTBOUND_ALLOW_PRIVATE_NETWORKS` | `false` | Allow other outbound fetches (for example OAuth metadata or client metadata documents) to private networks. |
| `OUTBOUND_ALLOW_HTTP_LOOPBACK` | `false` | Allow plain-HTTP loopback targets, for local testing. |
| `HTTPS_PROXY` | — | Proxy for outbound HTTPS. |

## Telemetry and web app

| Variable | Default | Description |
|---|---|---|
| `METRICS_ENABLED` | `true` | Serve Prometheus metrics at `/metrics`. |
| `METRICS_TOKEN` | — | If set, `/metrics` requires `Authorization: Bearer <token>`. |
| `OTEL_SDK_DISABLED` | `true` | Set to `false` to enable OpenTelemetry. Standard `OTEL_*` variables (`OTEL_EXPORTER_OTLP_ENDPOINT`, `OTEL_SERVICE_NAME`, `OTEL_RESOURCE_ATTRIBUTES`, `OTEL_METRICS_EXPORTER=otlp`) configure the exporters. |
| `WEB_DIST_DIR` | `../web/dist` | Location of the built web app. |
| `SERVE_WEB` | `true` in production | Serve the web app from the API server. |

See [Observability](https://neurouter.com/docs/observability) for details.

## Runtime settings

These are stored in the database and edited by admins in *Settings → Gateway settings* (or through the admin API). Defaults:

| Setting | Default |
|---|---|
| Audit retention | 90 days |
| Store full tool output in the audit log | off (outputs are stored as size and hash) |
| Metrics retention | 14 days of per-minute rollups, 400 days of hourly rollups |
| Approval timeout | 5 minutes (maximum 15) |
| Allow self-approval | off |
| Rate limit per agent | 600 per minute, burst 120 |
| Rate limit per agent and tool | 120 per minute, burst 30 |
| Session idle gap | 30 minutes |
| Catalog visibility | all servers visible in the portal (`all`) or only granted ones (`granted`) |
| OAuth dynamic client registration | on |
| Client ID metadata documents | any host, or an allowlist |
| Audit export | webhook and OpenTelemetry logs, both off |
