invoke-ai/InvokeAI · critical · RuntimeError
JWT secret not found in database. This should have been crea
Error message
JWT secret not found in database. This should have been created during database migration. Please ensure database migrations have been run successfully.
What it means
get_jwt_secret() reads the 'jwt_secret' key from the app-settings database and raises RuntimeError when it is absent. The secret is supposed to be created during database migrations, so its absence means the settings store was never migrated or the row was lost.
Source
Thrown at invokeai/app/services/app_settings/app_settings_service.py:70
ON CONFLICT(key) DO UPDATE SET
value = excluded.value,
updated_at = STRFTIME('%Y-%m-%d %H:%M:%f', 'NOW');
""",
(key, value),
)
def get_jwt_secret(self) -> str:
"""Get the JWT secret key from the database.
Returns:
The JWT secret key
Raises:
RuntimeError: If the JWT secret is not found in the database
"""
secret = self.get("jwt_secret")
if secret is None:
raise RuntimeError(
"JWT secret not found in database. This should have been created during database migration. "
"Please ensure database migrations have been run successfully."
)
return secret
View on GitHub (pinned to 0b6a024f2f)
Solutions
- Run database migrations (e.g. invokeai-db-maintenance / the app's migration path) so jwt_secret is created
- Back up and delete the old DB file (or just the stale settings table) and let InvokeAI re-initialize with fresh migrations
- Restore jwt_secret manually into the settings table if you need existing tokens to remain valid
Defensive patterns
Strategy: validation
Validate before calling
secret = app_settings.get("jwt_secret")
if secret is None:
raise RuntimeError("jwt_secret missing; run DB migrations first") Try / catch
try:
secret = app_settings.get_jwt_secret()
except RuntimeError:
run_database_migrations()
secret = app_settings.get_jwt_secret() Prevention
- Run migrations as part of every upgrade before starting the server
- Back up invokeai.db together with config when moving installs
- Never hand-edit the settings table
When it happens
Trigger: Any call to get_jwt_secret() when self.get('jwt_secret') returns None: running the app against a pre-migration or empty database, a DB file replaced or restored from an old backup without the jwt_secret row, or a failed/partial migration.
Common situations: Fresh checkout pointing at a stale invokeai.db; upgrading InvokeAI without running migrations; moving the DB between machines; manually editing/deleting rows in the settings table.
Related errors
- JWT secret has not been initialized. Call set_jwt_secret() d
- Failed to load and migrate v3 config file {config_path}: {e}
- Database contains unknown applied migration IDs: {unknown_id
- Database contains inconsistent applied migration state: {mig
- Database contains inconsistent applied migration state: {mig
AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29).
Data as JSON: /api/errors/cab603d9c6dbe5a9.
Report an issue: GitHub.