# Install libpq with Homebrew, apk, dnf, apt, Nix

Postgres C API library. Version 18.4 via Homebrew; verified 2026-06-28.

## Install

```sh
sudo av install brew:libpq
```

Additional install commands:

### macOS

- Homebrew (100%):

```sh
brew install libpq
```

  Evidence: local Homebrew formula metadata

### Linux

- apk (92%):

```sh
sudo apk add libpq
```

  Evidence: Alpine Linux edge package indexes: libpq from https://dl-cdn.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz

- dnf (92%):

```sh
sudo dnf install libpq
```

  Evidence: Fedora Rawhide package metadata: libpq from https://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/Everything/x86_64/os/repodata/e5ca8ce900cd68f5419e1c39ae517343100b306336cbaeb70a3c153121d95094-primary.xml.zst

- Debian apt (92%):

```sh
sudo apt install pg-checksums-doc
```

  Evidence: Debian stable package indexes: pg-checksums-doc from https://deb.debian.org/debian/dists/stable/main/binary-amd64/Packages.xz

- Nix (92%):

```sh
nix profile install nixpkgs#pg_checksums
```

  Evidence: nixpkgs package indexes: pkgs/by-name/pg/pg_checksums/package.nix from https://api.github.com/repos/NixOS/nixpkgs/git/trees/master?recursive=1

## Package facts

- **Package key:** brew:libpq
- **Package manager:** Homebrew
- **Package manager page:** <https://formulae.brew.sh/formula/libpq>
- **Version:** 18.4
- **Source summary:** Postgres C API library
- **Homepage:** <https://www.postgresql.org/docs/current/libpq.html>
- **Repository:** <https://git.postgresql.org/git/postgresql.git>
- **Upstream docs:** <https://www.postgresql.org/docs/current/libpq.html>
- **License:** PostgreSQL
- **Source archive:** <https://ftp.postgresql.org/pub/source/v18.4/postgresql-18.4.tar.bz2>
- **Last updated:** 2026-06-28T05:00:52Z
- **Generated:** 2026-07-08T07:18:31+00:00

## Executables

- clusterdb (cli)
- createdb (cli)
- createuser (cli)
- dropdb (cli)
- dropuser (cli)
- ecpg (cli)
- initdb (cli)
- pg_amcheck (cli)
- pg_archivecleanup (cli)
- pg_basebackup (cli)
- pg_checksums (cli)
- pg_combinebackup (cli)
- pg_config (cli)
- pg_controldata (cli)
- pg_createsubscriber (cli)
- pg_ctl (cli)
- pg_dump (cli)
- pg_dumpall (cli)
- pg_isready (cli)
- pg_receivewal (cli)
- pg_recvlogical (cli)
- pg_resetwal (cli)
- pg_restore (cli)
- pg_rewind (cli)
- pg_test_fsync (cli)
- pg_test_timing (cli)
- pg_upgrade (cli)
- pg_verifybackup (cli)
- pg_waldump (cli)
- pg_walsummary (cli)
- pgbench (cli)
- psql (cli)
- reindexdb (cli)
- vacuumdb (cli)
- clusterdb (alias)
- createdb (alias)
- createuser (alias)
- dropdb (alias)
- dropuser (alias)
- ecpg (alias)
- initdb (alias)
- pg_amcheck (alias)
- pg_archivecleanup (alias)
- pg_basebackup (alias)
- pg_checksums (alias)
- pg_combinebackup (alias)
- pg_config (alias)
- pg_controldata (alias)
- pg_createsubscriber (alias)
- pg_ctl (alias)
- pg_dump (alias)
- pg_dumpall (alias)
- pg_isready (alias)
- pg_receivewal (alias)
- pg_recvlogical (alias)
- pg_resetwal (alias)
- pg_restore (alias)
- pg_rewind (alias)
- pg_test_fsync (alias)
- pg_test_timing (alias)
- pg_upgrade (alias)
- pg_verifybackup (alias)
- pg_waldump (alias)
- pg_walsummary (alias)
- pgbench (alias)
- psql (alias)
- reindexdb (alias)
- vacuumdb (alias)

## Dependencies

- icu4c@78
- krb5
- openssl@3
- readline

## Build dependencies

- docbook
- docbook-xsl
- pkgconf

## Uses from macOS

- curl

## Install behavior

- Post-install hook: not defined
- Bottle: available on arm64_linux, arm64_sequoia, arm64_sonoma, arm64_tahoe, sonoma, x86_64_linux

## Freshness

- Page generated: 2026-07-08
- Package-manager version: 18.4
- Package-manager updated: 2026-06-28
- Local data: ok
- Upstream repository: https://www.postgresql.org/docs/current/libpq.html
- info: Release/tag comparison is only available for GitHub repositories.
## Project history and usage

libpq is PostgreSQL's C client library: the small, stable-looking surface that lets C programs connect to PostgreSQL servers, submit queries, and read results. It also underlies several other PostgreSQL client interfaces, so packaging it separately gives developers the client headers, shared library, and familiar tools without requiring a Homebrew PostgreSQL server installation.

### Project history

PostgreSQL descends from the Berkeley POSTGRES project, whose implementation began in 1986. The Postgres95 transition in 1994 replaced POSTQUEL with SQL and introduced `psql`; the PostgreSQL name arrived in 1996 to connect the POSTGRES heritage with SQL support.

The PostgreSQL manual notes that the `libpq` name came from PostQUEL. As PostgreSQL matured into a long-lived open source database, libpq became the canonical C API for client programs and a shared substrate for other language bindings and command-line clients.

### Adoption history

libpq's adoption follows PostgreSQL's adoption: applications, drivers, migration tools, backup tools, and admin scripts need a PostgreSQL client layer even when the database server runs elsewhere. PostgreSQL's 2023 project announcement described the system as benefiting from more than 25 years of open source development and a global community of users, contributors, companies, and organizations.

Homebrew's `libpq` formula packages the client side as a keg-only formula. That matters on developer workstations because it avoids colliding with a full `postgresql` formula while still making `psql`, `pg_dump`, `pg_restore`, `pg_config`, and the C library available to builds and scripts.

### How it is used

Typical package-manager use is installing libpq so native extensions, database drivers, and command-line workflows can compile or run against PostgreSQL. Developers use `pg_config` to find build flags, `psql` for interactive sessions, and the dump/restore utilities for movement between PostgreSQL instances.

### Why package nerds care

libpq is package-nerd significant because it is a dependency edge disguised as a database client. Many packages need PostgreSQL client headers and link libraries, but users often do not want a local database server; a separate formula keeps that dependency smaller and less invasive.

It also exposes PostgreSQL's major-version reality to package managers: client utilities can speak across versions, but dump, restore, upgrade, and extension-building workflows often care about exact major lines. That is why versioned formulae such as `libpq@16` and `libpq@17` are useful beside the unversioned formula.

### Timeline

- 1986: Implementation of the Berkeley POSTGRES project began at the University of California at Berkeley.
- 1994: Postgres95 added an SQL interpreter and `psql`, replacing POSTQUEL and the older monitor program.
- 1996: The project adopted the PostgreSQL name and reset version numbering to 6.0.
- 2023-09-14: PostgreSQL 16 was released, including libpq load-balancing support among its client-side changes.
- 2024-09-26: PostgreSQL 17 was released with new client and administration utilities including `pg_createsubscriber` and `pg_combinebackup`.

### Related projects

- PostgreSQL server, `psql`, ECPG, PostgreSQL client utilities, language drivers that use libpq, and Homebrew's versioned `libpq@16` and `libpq@17` formulae are the closest related projects.

### Sources

- <https://formulae.brew.sh/formula/libpq>
- <https://www.postgresql.org/about/news/postgresql-16-released-2715/>
- <https://www.postgresql.org/about/press/presskit17/>
- <https://www.postgresql.org/docs/current/history.html>
- <https://www.postgresql.org/docs/current/libpq.html>
- <https://www.postgresql.org/support/versioning/>


## Security Notes

No matching local secret-handling manifest was found for libpq. Nucleus package metadata is still published here so future coverage has a stable package URL.



## Configuration and credential file locations

These source-backed paths show where this package keeps local settings or durable credentials. Automic Vault can use them as review targets for secret scanning, migration, and command approval.


## Configuration files

- Unix: psqlrc in the directory reported by pg_config --sysconfdir, ~/.psqlrc, pg_service.conf in the directory reported by pg_config --sysconfdir, ~/.pg_service.conf
- Windows: %APPDATA%\postgresql\psqlrc.conf, %APPDATA%\postgresql\.pg_service.conf

## Credential files

- Unix: ~/.pgpass
- Windows: %APPDATA%\postgresql\pgpass.conf
## Source Database Details

- **Source Database:** Homebrew formula API
- **Tap:** homebrew/core
- **Full Name:** libpq
- **Aliases:** libpq@18
- **Version Scheme:** 0
- **Revision:** 0
- **Bottle Stable Root URL:** <https://ghcr.io/v2/homebrew/core>
- **Deprecated:** no
- **Disabled:** no
- **Keg Only:** yes
- **URL Keys:** stable

## Other Package-Manager Records

- apk - libpq - 18.4-r0: normalized package name match | Alpine Linux edge package indexes: libpq from https://dl-cdn.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz | PostgreSQL client library | https://www.postgresql.org/
- dnf - libpq - 18.4-1.fc45: normalized package name match | Fedora Rawhide package metadata: libpq from https://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/Everything/x86_64/os/repodata/e5ca8ce900cd68f5419e1c39ae517343100b306336cbaeb70a3c153121d95094-primary.xml.zst | PostgreSQL client library | http://www.postgresql.org/
- dnf - libpq-devel - 18.4-1.fc45: normalized package name match | Fedora Rawhide package metadata: libpq-devel from https://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/Everything/x86_64/os/repodata/e5ca8ce900cd68f5419e1c39ae517343100b306336cbaeb70a3c153121d95094-primary.xml.zst | Development files for building PostgreSQL client tools | http://www.postgresql.org/
- Debian apt - pg-checksums-doc - 1.2-2: installed executable or alias match | Debian stable package indexes: pg-checksums-doc from https://deb.debian.org/debian/dists/stable/main/binary-amd64/Packages.xz | Activate/deactivate/verify PostgreSQL data checksums (Documentation) | https://github.com/credativ/pg_checksums
- Debian apt - postgresql-17-pg-checksums - 1.2-2: installed executable or alias match | Debian stable package indexes: postgresql-17-pg-checksums from https://deb.debian.org/debian/dists/stable/main/binary-amd64/Packages.xz | Activate/deactivate/verify PostgreSQL data checksums | https://github.com/credativ/pg_checksums
- Nix - pg_checksums: installed executable or alias match | nixpkgs package indexes: pkgs/by-name/pg/pg_checksums/package.nix from https://api.github.com/repos/NixOS/nixpkgs/git/trees/master?recursive=1
- Ubuntu apt - pg-checksums-doc - 1.1-6: installed executable or alias match | Ubuntu 24.04 LTS package indexes: pg-checksums-doc from https://archive.ubuntu.com/ubuntu/dists/noble/universe/binary-amd64/Packages.gz | Activate/deactivate/verify PostgreSQL data checksums (Documentation) | https://github.com/credativ/pg_checksums
- Ubuntu apt - postgresql-16-pg-checksums - 1.1-6: installed executable or alias match | Ubuntu 24.04 LTS package indexes: postgresql-16-pg-checksums from https://archive.ubuntu.com/ubuntu/dists/noble/universe/binary-amd64/Packages.gz | Activate/deactivate/verify PostgreSQL data checksums | https://github.com/credativ/pg_checksums


## Related links

- [Terminal utility packages](https://www.automicvault.com/pkg/terminal-utilities/) - Matched terminal and command-line workflow metadata.
- [Text processing packages](https://www.automicvault.com/pkg/text-processing-tools/) - Matched text, document, or structured-data processing metadata.
- [Developer build packages](https://www.automicvault.com/pkg/developer-build-tools/) - Matched build, compiler, generator, or developer workflow metadata.
- [Networking and protocol packages](https://www.automicvault.com/pkg/networking-protocol-tools/) - Matched network, protocol, or remote-service metadata.
- [krb5](https://www.automicvault.com/pkg/brew/krb5/) - Runtime dependency declared by Homebrew.
- [openssl@3](https://www.automicvault.com/pkg/brew/openssl-3/) - Runtime dependency declared by Homebrew.
- [docbook](https://www.automicvault.com/pkg/brew/docbook/) - Build dependency declared by Homebrew.
- [docbook-xsl](https://www.automicvault.com/pkg/brew/docbook-xsl/) - Build dependency declared by Homebrew.
- [pkgconf](https://www.automicvault.com/pkg/brew/pkgconf/) - Build dependency declared by Homebrew.
- [barman](https://www.automicvault.com/pkg/brew/barman/) - Popular package that depends on this formula.
- [check_postgres](https://www.automicvault.com/pkg/brew/check-postgres/) - Popular package that depends on this formula.
- [coturn](https://www.automicvault.com/pkg/brew/coturn/) - Popular package that depends on this formula.
- [dexter](https://www.automicvault.com/pkg/brew/dexter/) - Popular package that depends on this formula.
- [diesel](https://www.automicvault.com/pkg/brew/diesel/) - Popular package that depends on this formula.
- [ephemeralpg](https://www.automicvault.com/pkg/brew/ephemeralpg/) - Popular package that depends on this formula.
- [eralchemy](https://www.automicvault.com/pkg/brew/eralchemy/) - Popular package that depends on this formula.
- [supabase](https://www.automicvault.com/pkg/brew/supabase/) - Shares av.db curated category or tags: cli, database, developer-tools, postgresql.
- [chdig](https://www.automicvault.com/pkg/brew/chdig/) - Shares av.db curated category or tags: cli, database, developer-tools.
- [dbhash](https://www.automicvault.com/pkg/brew/dbhash/) - Shares av.db curated category or tags: cli, database, developer-tools.
- [dblab](https://www.automicvault.com/pkg/brew/dblab/) - Shares av.db curated category or tags: cli, database, developer-tools, postgresql.
- [dbmate](https://www.automicvault.com/pkg/brew/dbmate/) - Shares av.db curated category or tags: cli, database, developer-tools, postgresql.
- [golang-migrate](https://www.automicvault.com/pkg/brew/golang-migrate/) - Shares av.db curated category or tags: cli, database, developer-tools.
- [postgresql@14](https://www.automicvault.com/pkg/brew/postgresql-14/) - Local metadata places this package in an adjacent workflow. Shared terms: database, icu4c, icu4c-78, krb5, openssl.
- [postgresql@15](https://www.automicvault.com/pkg/brew/postgresql-15/) - Local metadata places this package in an adjacent workflow. Shared terms: database, icu4c, icu4c-78, krb5, openssl.
- [postgresql@16](https://www.automicvault.com/pkg/brew/postgresql-16/) - Local metadata places this package in an adjacent workflow. Shared terms: database, icu4c, icu4c-78, krb5, openssl.

## Combined YAML source

View the package source record on GitHub. [combined/libpq.yml](https://github.com/automic-vault/db/blob/main/combined/libpq.yml)


## Sources

- Nucleus package database
- Geiger risk classifier
- package-page enrichment
- curated configuration and credential file locations
- curated package history
- package version freshness
- av.db category and tag curation
- package relationship graph
- external package-manager database matches
- cross-ecosystem install command graph
