nautechsystems/nautilus_trader · error

Signer private key environment variable

Error message

Signer private key environment variable '{}' is not set

What it means

The execution client loads its transaction-signing key exclusively from the environment variable named by config.signer_private_key_env. If that variable is unset, initialization aborts with this error; the key is deliberately never stored in config files or logs.

Solutions

  1. Export the variable in the process environment: export <VAR>=<hex key> before launching the process.
  2. Check the configured signer_private_key_env string matches the actual environment variable name exactly (case-sensitive).
  3. If using .env/docker/systemd, ensure the env file is actually loaded (docker --env-file, systemd EnvironmentFile, dotenv::dotenv().ok()).
  4. Verify secrets injection in CI/production (secrets mounted to env, correct secret key name).

Example fix

// before
# config: signer_private_key_env = "SIGNER_KEY"  (never exported)
./nautilus-blockchain

// after
export SIGNER_KEY=0x<64-hex-private-key>
./nautilus-blockchain
Defensive patterns

Strategy: validation

Validate before calling

let var_name = std::env::var("SIGNER_KEY_ENV_NAME").expect("config");
if std::env::var(&var_name).is_err() {
    panic!("required signer env var '{}' is not exported", var_name);
}

Try / catch

match client.connect().await {
    Err(e) if e.to_string().contains("is not set") => eprintln!("export the signer key env var and retry"),
    other => other.map(|_| ()),
}

Prevention

When it happens

Trigger: Client init/connect runs std::env::var(self.config.signer_private_key_env) and gets Err (VarError::NotPresent) — the variable name is set in config but not exported in the process environment.

Common situations: Variable defined in .env file that is never loaded (no dotenv/systemd EnvironmentFile), typo between the configured name and the exported name, running under a service manager that strips the environment, or deploying with a secrets manager that did not inject it.

Understand the failure class

Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08). Data as JSON: /api/errors/d4ee9ea9d1f004f1. Report an issue: GitHub.

Appendix: source

Thrown at crates/adapters/blockchain/src/execution/client.rs:6169

        }

        let payload_connect_lease = if let (Some(database), Some(keys)) =
            (self.cache.database.as_ref(), self.payload_keys.as_deref())
        {
            Some(
                database
                    .require_execution_payload_storage(keys, self.payload_policy(), 100)
                    .await?,
            )
        } else {
            None
        };

        // Load the signer key from the configured environment variable; the key is never
        // logged, serialized, or stored in configuration
        let private_key = Zeroizing::new(
            std::env::var(&self.config.signer_private_key_env).map_err(|_| {
                anyhow::anyhow!(
                    "Signer private key environment variable '{}' is not set",
                    self.config.signer_private_key_env
                )
            })?,
        );
        let encoded_key = private_key.trim();
        let encoded_key = encoded_key.strip_prefix("0x").unwrap_or(encoded_key);
        let key_bytes = Zeroizing::new(hex::decode_array::<32>(encoded_key).map_err(|_| {
            anyhow::anyhow!(
                "Signer private key in '{}' is not a valid hex private key",
                self.config.signer_private_key_env
            )
        })?);
        let signer = PrivateKeySigner::from_slice(&key_bytes[..]).map_err(|_| {
            anyhow::anyhow!(
                "Signer private key in '{}' is not a valid secp256k1 private key",
                self.config.signer_private_key_env
            )

View on GitHub (pinned to 18893faf8b)