⚠️ Note: This comment is not directly related to the installation failure described in this question, but I’m posting here because this thread ranks highly for the error message Database initialization failed, which can also occur in entirely different contexts (e.g., during application startup).
In my case, I encountered:
Failed to run Postgres database startup procedure. Errors:
DatabaseError [0001] Database initialization failed for quartz.
Exception: [NpgsqlException] Exception while reading from stream
After extensive investigation, it turned out the issue was due to stale or hanging connections in idle in transaction state — typically left open during debugging (e.g., force-quitting Visual Studio while a transaction is active). These sessions were holding locks on critical tables and blocking schema setup logic, causing misleading startup failures like the one above.
🔍 To investigate, I used:
SELECT
a.pid,
a.usename,
a.datname,
c.relname AS relation,
l.locktype,
l.mode,
l.granted,
a.state,
age(now(), a.query_start) AS running_for,
left(a.query, 80) AS query_snippet
FROM pg_locks l
LEFT JOIN pg_stat_activity a ON a.pid = l.pid
LEFT JOIN pg_class c ON c.oid = l.relation
ORDER BY l.granted DESC, a.pid;
✅ To resolve:
- Terminate stale sessions, we restarted db server.