N8n isn't accepting my PostgreSQL configuration

have configured my .env file to use PostgreSQL instead of SQLite3:

DB_TYPE=postgresdb
DB_POSTGRESDB_HOST=localhost
DB_POSTGRESDB_PORT=5432
DB_POSTGRESDB_DATABASE=n8n
DB_POSTGRESDB_USER=
DB_POSTGRESDB_PASSWORD=

User Management DB (must match main DB unless intentionally separate)

N8N_USER_MANAGEMENT_POSTGRESDB_HOST=localhost
N8N_USER_MANAGEMENT_POSTGRESDB_PORT=5432
N8N_USER_MANAGEMENT_POSTGRESDB_DATABASE=n8n
N8N_USER_MANAGEMENT_POSTGRESDB_USER=
N8N_USER_MANAGEMENT_POSTGRESDB_PASSWORD=

But I keep facing this error when trying to set up my local Ollama models:
Error in chat execution: Error: Could not locate the bindings file. Tried:
→ C:\Users\d-kin\AppData\Roaming\npm\node_modules\n8n\node_modules\sqlite3\build\node_sqlite3.node
→ C:\Users\d-kin\AppData\Roaming\npm\node_modules\n8n\node_modules\sqlite3\build\Debug\node_sqlite3.node
→ C:\Users\d-kin\AppData\Roaming\npm\node_modules\n8n\node_modules\sqlite3\build\Release\node_sqlite3.node
→ C:\Users\d-kin\AppData\Roaming\npm\node_modules\n8n\node_modules\sqlite3\out\Debug\node_sqlite3.node
→ C:\Users\d-kin\AppData\Roaming\npm\node_modules\n8n\node_modules\sqlite3\Debug\node_sqlite3.node
→ C:\Users\d-kin\AppData\Roaming\npm\node_modules\n8n\node_modules\sqlite3\out\Release\node_sqlite3.node
→ C:\Users\d-kin\AppData\Roaming\npm\node_modules\n8n\node_modules\sqlite3\Release\node_sqlite3.node
→ C:\Users\d-kin\AppData\Roaming\npm\node_modules\n8n\node_modules\sqlite3\build\default\node_sqlite3.node
→ C:\Users\d-kin\AppData\Roaming\npm\node_modules\n8n\node_modules\sqlite3\compiled\24.15.0\win32\x64\node_sqlite3.node
→ C:\Users\d-kin\AppData\Roaming\npm\node_modules\n8n\node_modules\sqlite3\addon-build\release\install-root\node_sqlite3.node
→ C:\Users\d-kin\AppData\Roaming\npm\node_modules\n8n\node_modules\sqlite3\addon-build\debug\install-root\node_sqlite3.node
→ C:\Users\d-kin\AppData\Roaming\npm\node_modules\n8n\node_modules\sqlite3\addon-build\default\install-root\node_sqlite3.node
→ C:\Users\d-kin\AppData\Roaming\npm\node_modules\n8n\node_modules\sqlite3\lib\binding\node-v137-win32-x64\node_sqlite3.node
Title generation failed: Error: Could not locate the bindings file. Tried:
→ C:\Users\d-kin\AppData\Roaming\npm\node_modules\n8n\node_modules\sqlite3\build\node_sqlite3.node
→ C:\Users\d-kin\AppData\Roaming\npm\node_modules\n8n\node_modules\sqlite3\build\Debug\node_sqlite3.node
→ C:\Users\d-kin\AppData\Roaming\npm\node_modules\n8n\node_modules\sqlite3\build\Release\node_sqlite3.node
→ C:\Users\d-kin\AppData\Roaming\npm\node_modules\n8n\node_modules\sqlite3\out\Debug\node_sqlite3.node
→ C:\Users\d-kin\AppData\Roaming\npm\node_modules\n8n\node_modules\sqlite3\Debug\node_sqlite3.node
→ C:\Users\d-kin\AppData\Roaming\npm\node_modules\n8n\node_modules\sqlite3\out\Release\node_sqlite3.node
→ C:\Users\d-kin\AppData\Roaming\npm\node_modules\n8n\node_modules\sqlite3\Release\node_sqlite3.node
→ C:\Users\d-kin\AppData\Roaming\npm\node_modules\n8n\node_modules\sqlite3\build\default\node_sqlite3.node
→ C:\Users\d-kin\AppData\Roaming\npm\node_modules\n8n\node_modules\sqlite3\compiled\24.15.0\win32\x64\node_sqlite3.node
→ C:\Users\d-kin\AppData\Roaming\npm\node_modules\n8n\node_modules\sqlite3\addon-build\release\install-root\node_sqlite3.node
→ C:\Users\d-kin\AppData\Roaming\npm\node_modules\n8n\node_modules\sqlite3\addon-build\debug\install-root\node_sqlite3.node
→ C:\Users\d-kin\AppData\Roaming\npm\node_modules\n8n\node_modules\sqlite3\addon-build\default\install-root\node_sqlite3.node
→ C:\Users\d-kin\AppData\Roaming\npm\node_modules\n8n\node_modules\sqlite3\lib\binding\node-v137-win32-x64\node_sqlite3.node

I am using Node v24.15.0, npm v11.12.1 and n8n v2.20.0

Could someone please help me understand why this is happening?

Hi :waving_hand: @Mr_Kintu

AI Agent nodes require sqlite3 even when using PostgreSQL. The error likely occurs because the sqlite3 package wasn’t properly compiled for your Node.js version. Node v24.15.0 has known compatibility issues with sqlite3 bindings.

The pre-built binaries don’t exist yet for Node 24, so you need to rebuild them manually using below commands

# Install Windows build tools
npm install --global windows-build-tools

# Then rebuild sqlite3
npm rebuild sqlite3

# Or reinstall n8n completely
npm uninstall -g n8n
npm install -g n8n

You can also consider downgrading to Node.js LTS (v20 or v22) which has better compatibility

# Using nvm (Node Version Manager)
nvm install 20
nvm use 20

# Then reinstall n8n
npm install -g n8n

Does that help?

Welcome to the community, @Mr_Kintu! And good catch from @kjooleng on the Node.js version.

To explain why this happens: the error Could not locate the bindings file for sqlite3 is a native module compatibility issue. The sqlite3 npm package bundles pre-compiled native binaries for specific Node.js versions. Node v24 is very new and the prebuilt binaries included in n8n’s dependencies may not have been compiled for it yet.

Here’s the thing: even though you’ve set DB_TYPE=postgresdb, n8n still has sqlite3 as a dependency in its package tree (it’s used internally for some fallback paths and gets loaded at startup regardless of your DB config). If the sqlite3 native binary can’t load for your Node version, it throws that error and n8n can’t start at all.

The fix: Use Node.js 20 LTS (the officially supported version for n8n). With nvm:

nvm install 20
nvm use 20
nvm alias default 20
npm install -g n8n

Node 18 LTS also works. Both are officially supported. Node 22 may work in some cases but 24 is not yet tested/supported as of n8n v2.20.

Once you’re on Node 20, your PostgreSQL config should be picked up correctly.

welcome to the n8n community @Mr_Kintu

One extra thing I would check after switching away from Node 24 is whether n8n is actually loading your .env values. Also, I would not leave DB_POSTGRESDB_USER and DB_POSTGRESDB_PASSWORD empty. Create a real PostgreSQL user, confirm the n8n database exists, then restart n8n completely. As a simpler workaround, Docker Compose with PostgreSQL may be more predictable than npm on Windows.

Thanks @kjooleng, I’ll try downgrading to node v22/v20 and use windows-build-tools to install the package! I’ll let you know how it goes

@tamy.santos oh no, those variable fields are real! It’s the binding issue that has been doing my head in. But thanks for sharing!

Thanks for this, @nguyenthieutoan & @kjooleng! Let me try these improvements out & return to you.