postgres server executable. Because it is 100% wire-compatible with PostgreSQL 18.3, you use the existing PostgreSQL client tools — initdb, psql, and any Postgres driver — to initialize, manage, and query it. The steps below get you from zero to a running server in under five minutes.
Prefer containers? See the Docker guide to run Pgrust with a single
docker run command — no client tools required.Install and Run
- macOS (Apple Silicon)
- Linux (Debian / Ubuntu)
1
Install PostgreSQL 18 client tools
Pgrust reuses the standard PostgreSQL You do not need to start the Homebrew-managed PostgreSQL service. Only the client tools are required.
initdb and psql utilities. Install them via Homebrew. Because postgresql@18 is a keg-only formula, Homebrew does not put its binaries on your PATH automatically - you must export the path yourself:2
Download the Pgrust binary
Download the latest pre-built binary and verify its checksum. Using Intel Mac: use
curl (rather than a browser download) avoids macOS Gatekeeper quarantine flags:macOS Gatekeeper: the binaries are not yet Apple-notarized. If you download with a browser instead of Or approve the binary under System Settings → Privacy & Security → Open Anyway.
curl, macOS may block execution. Clear the quarantine flag with:pgrust-0.2-macos-x86_64 in place of pgrust-0.2-macos-arm64. A universal binary (pgrust-0.2-macos-universal) covering both architectures is also available.3
Set required environment variables
Pgrust reads PostgreSQL’s shared data files (timezone data, error messages, etc.) at runtime. Without these two variables it looks in
/usr/local/pgsql/share and refuses to start:4
Initialize a data directory
Use the standard
initdb tool to create and initialize a PostgreSQL data directory:5
Start the Pgrust server
Start the server in the foreground. The You should see startup log output similar to a standard PostgreSQL server. The server listens on the Unix socket
ulimit and RUST_MIN_STACK settings prevent stack overflows on deep query plans:/tmp/.s.PGSQL.5432.6
Connect with psql and run a test query
Open a second terminal. Re-export the You should see
PATH if you haven’t added it to your profile, then connect via the Unix socket:pgrust 0.2 (PostgreSQL 18.3 compatible).Managing the Server
- Stop with
Ctrl-Cin the server terminal, orkill -INT <pid>. This triggers PostgreSQL’s fast shutdown and is safe. - Restart by re-running the same server command against the same data directory. Your data is preserved across restarts.
- Start over by deleting the data directory:
rm -rf /tmp/pgrust-data. This permanently deletes all data in it.
Troubleshooting
FATAL: lock file "/tmp/.s.PGSQL.5432.lock" already exists — another server (likely an existing Postgres install) is already using port 5432. Start Pgrust on a different port:SELECT version() to confirm you are talking to Pgrust and not a background Postgres instance.could not open directory "/usr/local/pgsql/share/timezone" — the PGRUST_PGSHAREDIR and PGRUST_TZDIR environment variables are not set in the shell running the server. Re-export them before starting.Using Other PostgreSQL Clients
Because Pgrust is 100% wire-compatible with PostgreSQL 18.3, any standard PostgreSQL client or driver works without modification:- GUI tools: pgAdmin, TablePlus, DBeaver, DataGrip
- Language drivers:
libpq,psycopg2/psycopg3(Python),node-postgres/pg(Node.js),pgx/lib/pq(Go),diesel/sqlx(Rust), JDBC (Java) - ORMs: SQLAlchemy, Prisma, ActiveRecord, Hibernate, GORM
Advanced: stdio-wire Transport
Thepostgres binary exposes a --stdio-wire flag that routes the PostgreSQL wire protocol over stdin/stdout instead of a network socket. This is an advanced transport used internally for the WebAssembly browser demo and differential testing. You do not need it for normal local or networked usage.
Building from Source
If you prefer to compile Pgrust yourself, or are targeting a platform without a pre-built binary, you can build from source. Rust 1.96.0 is pinned viarust-toolchain.toml and fetched automatically by rustup — you do not need to install a specific version manually.
1
Install build dependencies
Pgrust depends on Google’s RE2 regular expression library. Release builds refuse to compile without it on purpose — a build using only the fallback regex engine is drastically slower on regex-heavy workloads.
2
Clone the repository and build
target/release/postgres. A cold build on a modern laptop typically takes 5–10 minutes.The published downloadable binaries are built with
--profile dist, which enables fat LTO for a faster binary at the cost of a much longer compile time. For local development, --release is sufficient.3
Run the binary
Follow the same environment variable,
initdb, and startup steps from the platform tabs above, substituting target/release/postgres as the binary path.