---
title: Background server and key storage
description: "Start, stop, configure, pair, and rotate keys for the local background Executor server with executor service."
---

The local background Executor is a single per-data-directory server that every local `executor` command and the desktop app share (**Local** only; **Self-host** runs in Docker and **Cloud** is managed for you).

Run `executor service start` to start the background server without opening a browser, and `executor service status` to inspect its URL, version, and process ID.

**Prerequisites:** Executor 2.0.0-beta.79 installed via the [command line](/docs/run/cli) or the desktop app. When using an OS credential store (macOS Keychain, Windows Credential Manager, or Linux Secret Service), unlock it or grant access if prompted on first launch.

**You'll know it worked when** `executor service start` prints `http://127.0.0.1:4312` (or your configured port) and `executor service status` prints `http://127.0.0.1:4312 (version 2.0.0-beta.79, process <pid>)`.

## Manage the background server

The first command that needs the local server starts it: `executor`, `executor service start`, or any client command run without a remote host (such as `executor apps list` or `executor search`). It keeps running until you stop it or restart your computer.

| Command | Purpose |
| --- | --- |
| `executor service start` | Start the background server, or confirm it is running, and print its URL. |
| `executor service stop` | Stop the background server. |
| `executor service restart` | Stop the background server and start this installed version. |
| `executor service status` | Print its URL, version, and process ID (`starting`, `stopping`, or `not responding` while transitioning), or `stopped`. |
| `executor service get [<key>] [<name>]` | Print all settings as JSON, one setting (`port`, `env`, or `disabled`), or one `env` variable. |
| `executor service set <key> <value> [<env-value>]` | Change a setting. Changing `port` or `env`, or setting `disabled true`, stops the background server so the next start picks it up; setting `disabled false` only saves the setting. |
| `executor service unset <key> [<name>]` | Remove a setting (or one `env` variable). Unsetting `port` or `env` stops the background server; unsetting `disabled` only saves the setting. |
| `executor service pair` | Create and print a one-use dashboard connection link (valid for five minutes) for the running background server. |
| `executor service rotate-key` | Replace the saved managed local API key (leaving the encryption key unchanged). Run `executor service restart` to apply it, then update clients that used the old key. |

`executor service pair` waits up to 30 seconds if the server is starting, stopping, or temporarily unresponsive. It creates a one-use dashboard grant in server memory without starting Executor or writing local files or keys; keep the link private and use it within five minutes. Local clients normally authenticate with the registered per-start server credential. Set `EXECUTOR_API_KEY` alone when a client command (such as tool commands, `pair`, or `--server`) needs to authenticate with that key; if no background server is registered, `pair` targets the configured `EXECUTOR_PORT` (or default port `4312`).

To rotate an externally supplied API key, change it at its source and restart the server. `executor service rotate-key` applies only to managed keys and refuses external or uninitialized installations.

### Settings stored in `service.json`

| Setting | Purpose |
| --- | --- |
| `port` | Listening port (`1`–`65535`; default `4312`). The effective `EXECUTOR_PORT` takes precedence. Each data directory needs its own port. |
| `env` | Extra environment variables stored in `service.json` and passed to the background server: `executor service set env <name> <value>` and `executor service unset env <name>`. |
| `disabled` | Set to `true` to make `executor` and hostless client commands run a temporary private server (like `--standalone`) instead of the background server. `executor service start`, `executor service pair`, and the desktop app still use the background server. |

Changing or removing `port` or `env`, or setting `disabled true`, stops the running background server so the next start picks up the change; re-enabling the background server (`set disabled false` or `unset disabled`) only saves the setting. Values set in `service.json`'s `env` override the launching shell's values for the same variable, and the resulting `EXECUTOR_PORT` overrides `port`. Because `executor service set env` writes values as JSON in `service.json` and `executor service get` can print them, use `env` for non-secret settings such as `EXECUTOR_BROWSER_ORIGIN` and keep secrets out of service settings. `EXECUTOR_API_KEY` and `EXECUTOR_ENCRYPTION_KEY` are forwarded to the background server only when both are set; `EXECUTOR_API_KEY` alone is dropped when launching a background process and is used only as a caller credential on commands that consume it.

Inside the data directory (default `~/.executor/v2/cli`), `service.json` stores `port`, `env`, and `disabled`, `server.json` records the running URL, PID, and per-start server credential (used by local clients, pairing, and shutdown), and `.server.lock` prevents a second server from opening the same directory. Files created for keys, service settings, and registration use mode `0600` on POSIX.

### Foreground, standalone, and remote modes

- `executor serve` runs the local server in your terminal until Ctrl+C without opening a browser (stop the background server first). Other local commands use it while it runs.
- `executor --standalone` runs a private server on a free port for one command until Ctrl+C, reading its configuration from the launching process (without the persisted `service.json` `env` overlay). Stop the background server first or set `EXECUTOR_DATA_DIR` to another folder.
- `executor --server <url>` opens the dashboard of an already-running local server at `<url>`, using `EXECUTOR_API_KEY` or the saved local API key.

### Sharing with the desktop app

The desktop app shares the same background server and `~/.executor/v2/cli` data directory by default (desktop can override its directory independently). Stopping it from the CLI (`executor service stop` or changing a setting) shows it as stopped in the desktop app without restarting it automatically; it reconnects when a CLI command starts it or you click **Start**.

Older desktop releases kept a separate data folder. When that old desktop folder contains a Local `executor.pglite` database, a newer desktop app moves that data into `~/.executor/v2/cli` once without merging: if CLI data already existed there, desktop data replaces it and the old CLI folder (with apps, accounts, and `service.json`) moves to `~/.executor/v2/backups/cli-data-<time>`. The shared folder gets the old desktop port and the CLI's non-data-bound `env` settings; migration clears `disabled` and data-bound `env` variables (`EXECUTOR_PORT`, `EXECUTOR_KEY_STORAGE`, `EXECUTOR_API_KEY`, `EXECUTOR_ENCRYPTION_KEY`). The old desktop folder moves to `~/.executor/v2/backups/desktop-data-<time>` (or stays in place on another drive). If no legacy desktop database exists, CLI data is untouched.

## Configure it

| Variable | Purpose |
| --- | --- |
| `EXECUTOR_PORT` | Port to listen on (`1`–`65535`). Overrides `port` in `service.json`; default `4312`. |
| `EXECUTOR_DATA_DIR` | Data directory path. Default `~/.executor/v2/cli`. |
| `EXECUTOR_KEY_STORAGE` | `file` or `os`: choose key storage for a brand-new data directory. |
| `EXECUTOR_API_KEY` | Supplied local API key (at least 32 characters). Pair with `EXECUTOR_ENCRYPTION_KEY` for server startup; set alone for client requests. |
| `EXECUTOR_ENCRYPTION_KEY` | Supplied credential encryption key (exactly 64 hexadecimal characters). Must be paired with `EXECUTOR_API_KEY`. |
| `EXECUTOR_BROWSER_ORIGIN` | Exact HTTPS origin used when generating browser links. |
| `EXECUTOR_WEBHOOK_ORIGIN` | Exact HTTPS origin used when generating public app webhook URLs. Forward incoming webhook requests to the Local server if you use an external origin. |
| `EXECUTOR_NO_UPDATE_CHECK` | Set to `1` to skip the daily npm check for a newer release. |
| `DO_NOT_TRACK` or `EXECUTOR_DISABLE_ANALYTICS` | Set to `1` before startup to disable product [usage analytics](/docs/run/usage-analytics) and feedback (local tracing and log collection are separate). |

## Key storage

Executor encrypts saved account fields in PGlite (`EXECUTOR_DATA_DIR/executor.pglite`) with AES-256-GCM using a 64-hex-character key and a fresh random nonce, binding each record to its account ID. On first launch of a new data directory, Executor generates a local API key and credential encryption key and tries the OS credential store (macOS Keychain, Windows Credential Manager, or Linux Secret Service) under `com.usefulsoftware.executor.v2` (account ID in `installation.json`).

- **Absent OS credential store:** When the OS credential store is absent (for example on headless Linux without Secret Service, or Windows without a logon session) and `EXECUTOR_KEY_STORAGE=os` is not forced, Executor can save newly generated keys in `keys.json` (POSIX mode `0600`) inside a new data directory. Keep that directory private.
- **Locked or denied OS store:** If an OS store exists but is locked or access is denied, Executor stops startup without writing `keys.json`. Unlock the store (`gnome-keyring-daemon --unlock` on Linux or `security unlock-keychain` on macOS) or grant access, and try again.
- **Explicit choice on a new directory:** Set `EXECUTOR_KEY_STORAGE=file` to force `keys.json`, or `EXECUTOR_KEY_STORAGE=os` to require the OS store. An initialized directory keeps its recorded key source; a mismatch fails startup.
- **Supplied keys:** Supply both `EXECUTOR_API_KEY` (at least 32 characters) and `EXECUTOR_ENCRYPTION_KEY` (exactly 64 hexadecimal characters) from your secret manager before first start and on every start. Server startup records the external key source and leaves supplied keys in their original source. Saving them through `executor service set env` writes them to `service.json` and lets `executor service get` print them — keep secrets out of service settings.

## Back up your data and keys

Stop the background server before copying its data directory. Back up the entire data directory (`installation.json` and `executor.pglite`) **with** its matching key source: the `com.usefulsoftware.executor.v2` OS credential matching `installation.json`, the `keys.json` inside the directory, or both original supplied keys in your secret manager. Copying only the database is not enough; for an initialized installation, missing or mismatched keys stop startup and Executor does not generate replacements.

## Example

Start the background server, change its port and an environment variable, rotate its local API key, and verify status:

```bash
executor service start
executor service status
executor service set port 14312
executor service set env EXECUTOR_NO_UPDATE_CHECK 1
executor service get
executor service rotate-key
executor service restart
executor service status
```

Expected output from `executor service status` after restart:

```text
http://127.0.0.1:14312 (version 2.0.0-beta.79, process 3488)
```

To restore the default port and stop the server:

```bash
executor service unset port
executor service stop
executor service status
# stopped
```

## Limits

- The background server does not auto-start on OS boot; MCP clients connecting to `http://127.0.0.1:4312/mcp` receive connection refused after a reboot until you run `executor` or `executor service start`.
- Bare `executor` and `executor service restart` switch a running background server to the invoked version; other local client subcommands reuse a responsive registered server on whichever version is running.
- On Windows, package managers (`npm`, `pnpm`, `bun`, `yarn`) cannot replace binaries of a running process; run `executor service stop` before upgrading outside `executor upgrade`.
- `executor service set` takes positional arguments (`executor service set port 14312`), not flags.

## Related

- [Command line](/docs/run/cli)
- [Use Executor from a shell](/docs/run/cli/from-a-shell)
- [Upgrade and migrate from Executor 1](/docs/run/cli/upgrade)
- [Desktop troubleshooting](/docs/desktop/troubleshooting)
- [Usage analytics](/docs/run/usage-analytics)
