Skip to main content
Pgrust ships as a pre-built binary that replaces the standard 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

1

Install PostgreSQL 18 client tools

Pgrust reuses the standard PostgreSQL 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:
You do not need to start the Homebrew-managed PostgreSQL service. Only the client tools are required.
2

Download the Pgrust binary

Download the latest pre-built binary and verify its checksum. Using 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 curl, macOS may block execution. Clear the quarantine flag with:
Or approve the binary under System Settings → Privacy & Security → Open Anyway.
Intel Mac: use 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:
Add these lines (and the PATH export from Step 1) to your shell profile (~/.zshrc or ~/.bash_profile) so they are set automatically in every new session.
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 ulimit and RUST_MIN_STACK settings prevent stack overflows on deep query plans:
You should see startup log output similar to a standard PostgreSQL server. The server listens on the Unix socket /tmp/.s.PGSQL.5432.
6

Connect with psql and run a test query

Open a second terminal. Re-export the PATH if you haven’t added it to your profile, then connect via the Unix socket:
You should see pgrust 0.2 (PostgreSQL 18.3 compatible).

Managing the Server

  • Stop with Ctrl-C in the server terminal, or kill -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:
After connecting, always run 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
Use the standard PostgreSQL connection string format:
No special drivers, extensions, or configuration changes are needed on the client side.

Advanced: stdio-wire Transport

The postgres 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 via rust-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

The compiled binary lands at 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.