Skip to content

Recorder fails to store states or open database (sqlite3.OperationalError) #147246

@Arjen2403

Description

@Arjen2403

The problem

When using a clean Home Assistant OS installation with the recorder integration enabled and pointed to a valid db_url, the system either:

  • Fails to create the home-assistant_v2.db file entirely, or
  • Creates it, but no states or events tables are generated, or
  • (When the DB is manually initialized), state records are written with entity_id = NULL

The event bus confirms that state_changed events are being fired, and a debug automation confirms correct events including entity_id. However, the recorder either shuts down or fails silently, and the database remains empty or unusable.

What version of Home Assistant Core has the issue?

core-2025.6.1

What was the last working version of Home Assistant Core?

Unknown — this behavior appeared from first install (2025.6.1)

What type of installation are you running?

  • Home Assistant OS
  • Home Assistant Supervised
  • Home Assistant Container
  • Home Assistant Core

Integration causing the issue

recorder

Link to integration documentation on our website

https://www.home-assistant.io/integrations/recorder/

Example YAML snippet from configuration.yaml

recorder:
  db_url: sqlite:////homeassistant/home-assistant_v2.db
  purge_keep_days: 3
  commit_interval: 2

logger:
  default: warning
  logs:
    homeassistant.components.recorder: debug
    sqlalchemy.engine.Engine: info

input_number:
  test_value:
    name: Test Value
    initial: 0
    min: 0
    max: 100
    step: 1

script:
  test_logging_script:
    alias: Test Logging Script
    sequence:
      - repeat:
          count: 5
          sequence:
            - service: input_number.set_value
              data:
                entity_id: input_number.test_value
                value: 10
            - delay: "00:00:01"
            - service: input_number.set_value
              data:
                entity_id: input_number.test_value
                value: 20
            - delay: "00:00:01"
    mode: restart
    icon: mdi:repeat

Traceback/Error logs

sqlite3.OperationalError: unable to open database file
...
Recorder setup failed, recorder shutting down
...
No such table: states

When manually creating the database file, this happens:

SELECT entity_id, state FROM states;
-- returns multiple rows with entity_id = NULL

Additional information

  • The directory /homeassistant exists and has 755 permissions (confirmed via SSH).

  • When using the default config without db_url, Home Assistant still fails to create the default DB in /config/.

  • Event bus confirms state_changed events are fired correctly (confirmed via automation).

  • Environment:

    • SQLite 3.48
    • Python 3.13
    • Home Assistant OS 15.2
    • Core version: 2025.6.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions