Skip to content

USE_EMBEDDED_DB=true still connects to PostgreSQL if previously configured #1245

@mikrub

Description

@mikrub

Bug Description

Setting USE_EMBEDDED_DB="true" does not switch Khoj to use SQLite when PostgreSQL was previously configured/connected.

Steps to Reproduce

  1. Install Khoj with PostgreSQL backend configured
  2. Run: USE_EMBEDDED_DB="true" khoj --anonymous-mode
  3. Khoj still attempts to connect to PostgreSQL instead of using embedded SQLite

Expected Behavior

When USE_EMBEDDED_DB="true" is set, Khoj should use the embedded SQLite database regardless of any existing PostgreSQL configuration.

Actual Behavior

Khoj ignores the environment variable and continues to use PostgreSQL, leading to errors if the PostgreSQL schema has issues.

Environment

  • Khoj version: 1.42.10
  • Python: 3.12.12
  • OS: macOS (Darwin 25.2.0)

Additional Context

This was discovered while trying to work around issue #1244 (migration mismatch). Setting USE_EMBEDDED_DB="true" was attempted as a workaround but the env var was not respected.

The documentation at https://docs.khoj.dev/get-started/setup/ suggests this should work:

USE_EMBEDDED_DB="true" khoj --anonymous-mode

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions