PostgreSQL · sdk · fg-0270

node-postgres fails with 'SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a string'

If you see Error: SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a string, the cause and the fix for PostgreSQL are below, last verified 2026-10-15.

Verified Oct 2026trust 50/100
Symptom
Error: SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a stringWorks in one shell or locally and fails in another shell or in the deployed environment
Cause
The password reached pg as undefined, almost always because the database URL or PGPASSWORD was not loaded into the process. PostgreSQL 14 made scram-sha-256 the default password encryption, so the failure surfaces inside the SCRAM handshake instead of as a plain login error.
Fix
Load the environment before creating the pool and fail fast when the URL is missing.
Apply
import 'dotenv/config' import pg from 'pg' if (!process.env.DATABASE_URL) throw new Error('DATABASE_URL is not set') export const pool = new pg.Pool({ connectionString: process.env.DATABASE_URL })
Affected
pg 8.x against PostgreSQL 14 and later, or any server using scram-sha-256
Sources

Last verified 2026-10-15 · Confirmed by 0 builders

Related traps

Have your agent know this before it fails

$ /plugin marketplace add getfootgun/footgun
$ /plugin install footgun@footgun