Postgres password error fix
No config path provided, using default 'drizzle.config.ts'
Reading config file 'C:\Users\Developer\Documents\cv-builder-backend\drizzle.config.ts'
Using 'pg' driver for database querying
[⣷] applying migrations...DrizzleQueryError: Failed query: CREATE SCHEMA IF NOT EXISTS
"drizzle"
params:
at NodePgPreparedQuery.queryWithCache (C:\Users\Developer\Documents\cv-builder-
backend\node_modules\src\pg-core\session.ts:73:11)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async PgDialect.migrate (C:\Users\Developer\Documents\cv-builder-
backend\node_modules\src\pg-core\dialect.ts:85:3)
at async migrate (C:\Users\Developer\Documents\cv-builder-
backend\node_modules\src\node-postgres\migrator.ts:10:2) {
query: 'CREATE SCHEMA IF NOT EXISTS "drizzle"',
params: [],
cause: Error: SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a string
at C:\Users\Developer\Documents\cv-builder-backend\node_modules\pg-pool\index.js:45:11
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async <anonymous> (C:\Users\Developer\Documents\cv-builder-
backend\node_modules\src\node-postgres\session.ts:149:14)
at async NodePgPreparedQuery.queryWithCache (C:\Users\Developer\Documents\cv-
builder-backend\node_modules\src\pg-core\session.ts:71:12)
at async PgDialect.migrate (C:\Users\Developer\Documents\cv-builder-
backend\node_modules\src\pg-core\dialect.ts:85:3)
at async migrate (C:\Users\Developer\Documents\cv-builder-
backend\node_modules\src\node-postgres\migrator.ts:10:2)
}
PS C:\Users\Developer\Documents\cv-builder-backend>
Got it👍
That error is coming from the Postgres client (pg) when Drizzle tries to apply migrations. The key part
is:
vbnet
SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a string
This means your database password is either not being passed correctly, or it's not a string
(possibly undefined, null, or a number).
Common causes & fixes:
1. Check your .env or config
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 1/3
env
DATABASE_URL=postgres://user:password@localhost:5432/dbname
Make sure password is a proper string.
No surrounding quotes unless part of the password.
If password has special characters (@, #, :), they must be URL encoded.
Example:
Password is My@Pass#123 → URL should be:
perl
postgres://user:My%40Pass%23123@localhost:5432/dbname
2. Check your drizzle.config.ts
If you’re using something like:
ts
import { defineConfig } from "drizzle-kit";
export default defineConfig({
schema: "./src/schema/*",
out: "./drizzle",
driver: "pg",
dbCredentials: {
connectionString: process.env.DATABASE_URL!,
},
});
Make sure process.env.DATABASE_URL is actually loaded. Try logging it:
ts
console.log("DATABASE_URL:", process.env.DATABASE_URL);
If it prints undefined, you need to load dotenv:
ts
import "dotenv/config";
3. If using separate credentials instead of a URL
ts
dbCredentials: {
user: process.env.DB_USER!,
password: process.env.DB_PASSWORD!, // must be a string
host: process.env.DB_HOST!,
port: Number(process.env.DB_PORT || 5432),
database: process.env.DB_NAME!,
}
Make sure you’re not accidentally passing a number (e.g., password=12345 without quotes in .env).
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 2/3
✅ Quick test:
Run in Node REPL inside your project:
js
require("dotenv").config();
console.log(typeof process.env.DB_PASSWORD, process.env.DB_PASSWORD);
If it logs undefined or anything other than "string", that’s the problem.
Do you want me to help rewrite your drizzle.config.ts in a safe way that ensures the password is
always treated as a string?
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 3/3