Comfy-Org/ComfyUI · error · ValueError
Unsupported database URL '{url}'.
Error message
Unsupported database URL '{url}'. What it means
Raised by get_db_path() when args.database_url does not start with 'sqlite:///'. This ComfyUI-asset server's database layer only supports SQLite, and the URL convention is fixed: everything after 'sqlite:///' is taken as the file path. Any other scheme (postgres://, mysql://, or a bare path) is rejected upfront.
Source
Thrown at app/database/db.py:70
def get_alembic_config():
root_path = os.path.join(os.path.dirname(__file__), "../..")
config_path = os.path.abspath(os.path.join(root_path, "alembic.ini"))
scripts_path = os.path.abspath(os.path.join(root_path, "alembic_db"))
config = Config(config_path)
config.set_main_option("script_location", scripts_path)
config.set_main_option("sqlalchemy.url", args.database_url)
return config
def get_db_path():
url = args.database_url
if url.startswith("sqlite:///"):
return url.split("///")[1]
else:
raise ValueError(f"Unsupported database URL '{url}'.")
_db_lock = None
def _acquire_file_lock(db_path):
"""Acquire an OS-level file lock to prevent multi-process access.
Uses filelock for cross-platform support (macOS, Linux, Windows).
The OS automatically releases the lock when the process exits, even on crashes.
"""
global _db_lock
lock_path = db_path + ".lock"
_db_lock = FileLock(lock_path)
try:
_db_lock.acquire(timeout=0)
except Timeout:
raise RuntimeError(
f"Could not acquire lock on database '{db_path}'. "View on GitHub (pinned to 1c6d8d45b3)
Solutions
- Use a SQLite URL: --database-url sqlite:///absolute/or/relative/path.db (three slashes then the path).
- If you actually need a network database, this build does not support it — remove the env override and use the default SQLite location, or patch the layer yourself.
- In Docker/CI, set DATABASE_URL='sqlite:////data/assets.db' (four slashes for absolute path) and ensure the directory exists and is writable.
Example fix
# before DATABASE_URL=postgres://user:pass@db/assets # after DATABASE_URL=sqlite:////data/assets.db
Defensive patterns
Strategy: validation
Validate before calling
import re
SQLITE_URL = re.compile(r'^sqlite:///\S.*$')
def usable_db_url(url: str) -> bool:
return bool(SQLITE_URL.match(url)) Type guard
def is_sqlite_url(url: str) -> bool:
return isinstance(url, str) and url.startswith('sqlite:///') Try / catch
try:
db_path = get_db_path()
except ValueError as e:
raise SystemExit(f'bad --database-url: {e}') from e Prevention
- Always launch with sqlite:///<path> (three slashes relative, four for absolute)
- Don't reuse DATABASE_URL values from Postgres/MySQL services
- Fail fast at startup on non-sqlite URLs instead of at first query
- In containers, verify the target directory exists and is writable
When it happens
Trigger: Launching the server with --database-url postgresql://... or DATABASE_URL=mysql://...; or passing a bare relative path like 'data.db' without the sqlite:/// prefix; or 'sqlite:///' vs 'sqlite://' (two slashes = empty host, still fails the startswith check only if not matching exactly).
Common situations: Reusing a DATABASE_URL from another service that runs Postgres/MySQL; CI env vars carrying a generic connection string; docs/examples that show bare paths; porting expectations from an ORM stack that accepts many schemes.
Related errors
- Could not acquire lock on database '{db_path}'. Another Comf
- ASSET_NOT_FOUND
- INVALID_BODY
- ASSET_NOT_FOUND
- no base path configured for category '{folder_name}'
AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14).
Data as JSON: /api/errors/ee45ced514275bb5.
Report an issue: GitHub.