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

Postgres C API library. Version 18.4 via Homebrew; verified from local package data. Also installable with apk: sudo apk add libpq.

## 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/07190dc5ae9f35ae73866675fed6d95fe6e8d9fe22c9d7cdf85862cb2ed24a4c-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
- **Version:** 18.4
- **Source summary:** Postgres C API library
- **Homepage:** <https://www.postgresql.org/docs/current/libpq.html>
- **Generated:** 2026-08-03T19:37:03+00:00

## Executables

- 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)

## Install behavior

- Bottle: not available

## Freshness

- Page generated: 2026-08-03
- Package-manager version: 18.4
## 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
## 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-4.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/07190dc5ae9f35ae73866675fed6d95fe6e8d9fe22c9d7cdf85862cb2ed24a4c-primary.xml.zst | PostgreSQL client library | http://www.postgresql.org/
- dnf - libpq-devel - 18.4-4.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/07190dc5ae9f35ae73866675fed6d95fe6e8d9fe22c9d7cdf85862cb2ed24a4c-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


## Combined YAML source

View the package source record on GitHub. [combined/libpq.yml](https://github.com/mxcl/pkgdb/blob/main/combined/libpq.yml)


## Sources

- pkg.so package database
- Geiger risk classifier
- curated configuration and credential file locations
- curated package history
- pkgdb category and tag curation
- external package-manager database matches
- cross-ecosystem install command graph
