Weights & Biases "Network error / no API key" in CI
wandb.init tried to start a run and either found no API key to authenticate or could not reach the wandb backend. In CI this is almost always a missing WANDB_API_KEY or a runner with no egress.
What this error means
A step fails or hangs with "wandb: ERROR api_key not configured (no-tty)" or "wandb: Network error (ConnectionError), entering retry loop" during wandb.init.
wandb: ERROR api_key not configured (no-tty). call wandb.login(key=[your_api_key])
wandb: ERROR Network error (ConnectionError), entering retry loop.Common causes
No WANDB_API_KEY in the CI environment
There is no interactive login in CI, so without WANDB_API_KEY wandb cannot authenticate and refuses to start a run.
A runner that cannot reach the wandb backend
Blocked egress or a transient network failure stops wandb from contacting the server, so it enters a retry loop.
How to fix it
Provide the API key via a secret
Expose WANDB_API_KEY from a CI secret so wandb authenticates non-interactively.
env:
WANDB_API_KEY: ${{ secrets.WANDB_API_KEY }}Run wandb offline or disabled in tests
When tests do not need to log to the server, set offline or disabled mode so no network or key is required.
export WANDB_MODE=offline # or: export WANDB_MODE=disabledHow to prevent it
- Store
WANDB_API_KEYas a CI secret for jobs that log runs. - Use
WANDB_MODE=disabledin unit tests that should not log. - Cache or sync offline runs after the job instead of logging live.