Run a local PostgreSQL instance in your project folder with one command.
bunx pg-hereDefault output:
Launching PostgreSQL 18.0.0 into new pg_local/
psql postgresql://postgres:postgres@localhost:55432/postgres
If a data folder already exists:
Reusing existing pg_local/data/ with PostgreSQL 18.0.0
psql postgresql://postgres:postgres@localhost:55432/postgres
If the cached folder version differs:
Reusing existing pg_local/data/ (pg_local/bin has 18.0.0, running PostgreSQL is 18.0)
psql postgresql://postgres:postgres@localhost:55432/postgres
The process stays alive until you stop it.
Ctrl+C → exits and stops Postgres.
bunx pg-here
username = postgrespassword = postgresdatabase = postgresport = 55432pg-version= auto
bunx pg-here --username me --password secret --database my_app --port 55433 --pg-version 17.0.0You can also run locally in this repo:
bun run db:upSame CLI flags are supported.
import { startPgHere } from "pg-here";
const pg = await startPgHere({
projectDir: process.cwd(),
database: "my_app",
createDatabaseIfMissing: true,
});
console.log(pg.databaseConnectionString); // psql-ready URL
await pg.stop();If startup fails with missing libxml2 libraries, install runtime packages and retry:
sudo apt-get update && sudo apt-get install -y libxml2 libxml2-utils
sudo dnf install -y libxml2
sudo apk add libxml2This release already retries startup with a project-local libxml2 compatibility fallback when needed.
If your environment keeps resolving an older release, force a specific version:
bunx [email protected]