A CLI tool and Node.js module that polls a PostgreSQL server until a connection succeeds or a custom query returns valid results. Version 1.5.3 is stable, with infrequent releases. It is lightweight (no production dependencies) and synchronous by default, distinguishing it from async-oriented alternatives like pg-pool or custom loops. Suitable for Docker entrypoints, CI scripts, and deployment automation.
npm install wait-for-postgresNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Waits for Postgres to accept connections using environment variables for config.
Use a wrapper with setTimeout or kill the process externally.
Use environment variables or a config file for passwords.
Use a more modern alternative like pg-pool or custom async loop with AbortController.
Ensure your query is idempotent and always succeeds on a valid connection.
Wrap wait() in additional error handling to differentiate.
Run 'npm install wait-for-postgres' in your project directory.
Use 'const { wait } = require('wait-for-postgres')'Verify your database is started and connection parameters (host, port) are correct.