Registry / database / is-postgres

is-postgres

JSON →
library0.2.0jsnpmunverified

A simple utility to check if a PostgreSQL database server is running. The latest stable version is v0.2.0, released in 2014. It provides both callback and promise APIs, as well as a CLI tool. No longer actively maintained; considered feature-complete for its narrow scope. Alternatives include more comprehensive database health-check libraries.

npm install is-postgres
INSTALL
IMPORT
SIG · IS-POSTGRES
I
is-postgres
databasejavascriptv0.2.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

isPostgres
import isPostgres from 'is-postgres'
ESM named default import. The package does not ship TypeScript types.
isPostgres
const isPostgres = require('is-postgres')
const isPostgres = require('./is-postgres')
CommonJS require; avoid local path as it's an npm package.
isPostgres
import { isPostgres } from 'is-postgres'
import { isPostgres } from 'is-postgres'
Named import works in ESM, but typically a default import is used. Both are supported.

Shows both callback and promise usage to check if PostgreSQL is running.

const isPostgres = require('is-postgres'); // Check if Postgres is running (callback) isPostgres((db) => { console.log('Running:', db.running); // true or false if (db.running) { console.log('Type:', db.type); // 'postgres' } }); // Promise-based isPostgres().then((db) => { console.log('Running:', db.running); });
Debug
Known issues
gotchaThe package only checks if PostgreSQL is listening on the default port (5432); it does not verify database connectivity or authentication.
fix
Use a more comprehensive tool like pg-ping or a full database connection test for production checks.
affects: >=0.0.0
deprecatedCallback API is deprecated in favor of Promises, though still supported in current versions.
fix
Use the promise-based API: isPostgres().then(...) or use async/await.
affects: >=0.2.0
gotchaThe CLI command is 'is-postgres' but global installation is required; may conflict with other packages using the same command name.
fix
Use npx is-postgres to avoid global install, or check the package.json bin entry.
affects: >=0.0.0
Errors
Common errors & fixes
Cannot find module 'is-postgres'
Package not installed or not in node_modules.
fix
Run 'npm install is-postgres' in your project directory.
isPostgres is not a function
Incorrect import: using a named import when a default import is required.
fix
Use 'const isPostgres = require("is-postgres");' or 'import isPostgres from "is-postgres";'.
Upgrade
Version history
0.2.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
is-postgres — npm install is-postgres · libregistry