High severity beginner · Fix: 2-5 min

wandb.errors.CommError

wandb.errors.CommError: run already finished log error

What this error means
This error occurs when attempting to log metrics or artifacts to a Weights & Biases run that has already been marked as finished or closed.

Stack trace

traceback
wandb.errors.CommError: run already finished, cannot log new data
  File "/usr/local/lib/python3.9/site-packages/wandb/sdk/wandb_run.py", line 1234, in log
    raise CommError("run already finished, cannot log new data")
  File "/app/train.py", line 56, in train_loop
    wandb.log({'loss': loss})  # triggers error
QUICK FIX
Move all wandb.log() calls to before wandb.finish() and add guards to prevent logging after run completion.

Why it happens

Weights & Biases runs have a lifecycle state; once a run is finished or closed, the backend disallows further logging to maintain data integrity. Attempting to log after calling wandb.finish() or after an unexpected run termination triggers this error.

Detection

Monitor your code to ensure wandb.log() calls occur only before wandb.finish() is called, and add checks or flags to prevent logging after run completion.

Causes & fixes

1

Calling wandb.log() after wandb.finish() has been invoked

✓ Fix

Ensure all logging calls happen before calling wandb.finish(), and avoid any asynchronous logging after finish.

2

The run was terminated unexpectedly or timed out, marking it finished on the server side

✓ Fix

Add error handling to detect run state and restart or create a new run if the previous one is finished.

3

Multiple processes or threads trying to log to the same run after it finished

✓ Fix

Synchronize logging calls and ensure only one process controls the run lifecycle, or use separate runs per process.

Code: broken vs fixed

Broken - triggers the error
python
import wandb

wandb.init(project="my-project")
wandb.finish()
wandb.log({"accuracy": 0.95})  # triggers run already finished log error
Fixed - works correctly
python
import os
import wandb

os.environ["WANDB_API_KEY"] = os.getenv("WANDB_API_KEY")  # Use env var for API key
run = wandb.init(project="my-project")
wandb.log({"accuracy": 0.95})  # log before finish
wandb.finish()  # finish after all logging
print("Logged successfully before finishing run.")
Moved wandb.log() before wandb.finish() to ensure logging happens while the run is active, preventing the error.

Workaround

Wrap wandb.log() calls in try/except wandb.errors.CommError, and on catching the error, skip logging or restart a new run to continue logging.

Prevention

Design your training or evaluation loops to complete all logging before calling wandb.finish(), and avoid asynchronous or delayed logging after run closure.

Python 3.7+ · wandb >=0.10.0 · tested on 0.14.0
Verified 2026-04
Verify ↗

Community Notes

No notes yetBe the first to share a version-specific fix or tip.