HumanSignal / HumanSignal/label-studio

RuntimeWarning: Accessing the database during app initialization on Docker startup (Django 5.1

Open
#9,715 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
28.3k
Forks
3.7k
Avg merge
14h
Merged PRs (30d)
15

Description

### Describe the bug

On a clean Docker start of heartexlabs/label-studio:latest, Django prints a RuntimeWarning that the database is being accessed during app initialization. The process still continues (“Initializing database..”, server listens on port 8080), but the warning indicates an unsupported lifecycle pattern on Django 5.1.
```

/label-studio/.venv/lib/python3.13/site-packages/django/db/backends/utils.py:98: RuntimeWarning: Accessing the database during app initialization is discouraged. To fix this warning, avoid executing queries in AppConfig.ready() or when your app modules are imported.
warnings.warn(self.APPS_NOT_READY_WARNING_MSG, category=RuntimeWarning)
```

### To Reproduce

1. Ensure Docker is running.
2. Run:
`docker run -it -p 8080:8080 -v $(pwd)/mydata:/label-studio/data heartexlabs/label-studio:latest`
3. (use an empty or new mydata directory if you want a fresh DB.)
4. Watch container stdout during startup (before/around “Initializing database..”).
5. See the `RuntimeWarning` above.

### Expected behavior

Startup should not trigger Django’s “accessing the database during app initialization” warning, or the project should document why it is unavoidable.

Screenshots

N/A (warning is in container logs only).

### Environment (please complete the following information):

- OS: macOS (host); container base per official image.
- Label Studio Version: heartexlabs/label-studio:latest (e.g. image pulled 2026-04-30; optional: add docker image inspect heartexlabs/label-studio:latest --format '{{.RepoDigests}}' and/or run label-studio --version inside the container for an exact build).
- Django (from logs): 5.1.15 (core.settings.label_studio).
- Python (from traceback path): 3.13 in image venv.

### Additional context

- Startup log also showed SECRET_KEY not set and a random key generated (/label-studio/data/.env not found), plus a PyPI request for label-studio metadata shortly before the warning; not sure if that path is related.
- Server still reported: Starting development server at http://0.0.0.0:8080/

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.