mlflow/mlflow · error · Exception
Run with UUID {} is already active. To start a new run, firs
Error message
Run with UUID {} is already active. To start a new run, first end the current run with mlflow.end_run(). To start a nested run, call start_run with nested=True What it means
mlflow.start_run() maintains an active-run stack; a plain (non-nested) start_run while a run is already active on the stack is ambiguous and rejected. The error names the currently active run UUID and points to end_run() or nested=True.
Source
Thrown at mlflow/tracking/fluent.py:567
.. code-block:: text
:caption: Output
parent run:
run_id: 8979459433a24a52ab3be87a229a9cdf
description: starting a parent for experiment 7
version tag value: v1
priority tag value: P1
--
child runs:
run_id params.child tags.mlflow.runName
0 7d175204675e40328e46d9a6a5a7ee6a yes CHILD_RUN
"""
active_run_stack = _active_run_stack.get()
_validate_experiment_id_type(experiment_id)
# back compat for int experiment_id
experiment_id = str(experiment_id) if isinstance(experiment_id, int) else experiment_id
if len(active_run_stack) > 0 and not nested:
raise Exception(
(
"Run with UUID {} is already active. To start a new run, first end the "
+ "current run with mlflow.end_run(). To start a nested "
+ "run, call start_run with nested=True"
).format(active_run_stack[0].info.run_id)
)
client = MlflowClient()
sgc_job_run_id_tag_key: str | None = None
if run_id:
existing_run_id = run_id
elif run_id := MLFLOW_RUN_ID.get():
existing_run_id = run_id
del os.environ[MLFLOW_RUN_ID.name]
# Get SGC job run ID tag key for run resumption if applicable
elif sgc_job_run_id_tag_key := _get_sgc_job_run_id_tag_key():
existing_run_id = _get_sgc_mlflow_run_id_for_resumption(
client, experiment_id, sgc_job_run_id_tag_key
)View on GitHub (pinned to 6a27f2decc)
Solutions
- Use `with mlflow.start_run(nested=True):` for the inner run.
- Call mlflow.end_run() before starting a new top-level run, or use separate `with mlflow.start_run():` blocks.
- Restructure so each run is properly closed (e.g., don't call start_run in a callback that runs inside an active run).
- If a stale run is stuck from a crashed process, it no longer affects a new process; just ensure this process's stack is clean.
Example fix
// before
with mlflow.start_run():
with mlflow.start_run(): # raises
train()
// after
with mlflow.start_run():
with mlflow.start_run(nested=True):
train() Defensive patterns
Strategy: validation
Validate before calling
if mlflow.active_run() is not None:
mlflow.end_run() # or use nested=True Type guard
def has_active_run() -> bool:
return mlflow.active_run() is not None Try / catch
try:
mlflow.start_run()
except Exception as e:
if "already active" in str(e):
mlflow.end_run()
run = mlflow.start_run()
else:
raise Prevention
- Always use context managers (with mlflow.start_run():) so runs auto-close
- Use nested=True for inner runs
- Don't call start_run inside callbacks that run within an active run
When it happens
Trigger: Calling mlflow.start_run() (or the context manager) while _active_run_stack is non-empty and nested is not True — e.g., nested start_run calls in a loop, or re-entering start_run inside an active `with mlflow.start_run():` block.
Common situations: Calling start_run twice in the same script without ending the first run; wrapping training steps in start_run inside an outer start_run without nested=True; a callback (e.g., on_evaluate_start) starting a run while the framework already has one active.
Related errors
- Current run with UUID {current_run_id} does not match the sp
- INVALID_PARAMETER_VALUE
- INVALID_PARAMETER_VALUE
- Cannot start run with ID {existing_run_id} because it is in
- Failed to parse trace data JSON: ${error instanceof Error ?
AI-assisted analysis of mlflow/mlflow@6a27f2decc (2026-08-29).
Data as JSON: /api/errors/05662c1b6742f931.
Report an issue: GitHub.