A short post about two parameters that were a charming idea in 2002 and have aged into a curiosity.
bonjour, when on, makes the PostgreSQL server advertise itself on the local network via Apple’s Bonjour service-discovery protocol (mDNS/DNS-SD). bonjour_name sets the name under which it advertises, defaulting to the computer’s hostname. Both are postmaster context — change them in postgresql.conf and restart. Both default to off (or empty), and bonjour only does anything if PostgreSQL was compiled with --with-bonjour, which most distribution packages are not.
The motivating idea: spin up a PostgreSQL server on the office network and have it discoverable in Finder under Network → Bonjour Services. Click, connect, query. Zero-configuration networking, the way Apple envisioned it. The server announces itself as a _postgresql._tcp. service on the .local multicast domain. Bonjour-aware clients see it and offer it as a connection target. No DNS entries, no IP addresses to memorize, no service registry.
In practice, you may have observed that this is not how production PostgreSQL gets deployed.
The use case the feature was built for — local-network ad-hoc database discovery on a small developer or workgroup network, primarily macOS-to-macOS — was always niche, and the universe of people running PostgreSQL servers that other Macs on the same physical LAN are supposed to find automatically is small enough that I have not seen this parameter set to on in a production environment in fifteen years of doing this work. The legitimate use cases that remain are:
- Conference demos on a private wireless network.
- Small classroom setups where students need to find an instructor’s database without typing IP addresses.
- Home lab tinkering where the convenience is the point.
In all of these, the cost of the parameter is low and the convenience is real. Outside of them, it is a service-discovery advertisement on a network where PostgreSQL almost certainly does not want to advertise itself — production databases live on private network segments, behind firewalls, in cloud VPCs, or in Kubernetes service meshes, and broadcasting “here I am, I am PostgreSQL” to anything that can hear 224.0.0.251 is not the security posture most operators are going for.
A few practical notes:
- Most distribution packages don’t include Bonjour support. Debian, Red Hat, Ubuntu, and the EDB community installer all build without
--with-bonjour. Settingbonjour = onin those builds produces a startup warning and otherwise does nothing. - macOS Homebrew builds do include it. If you
brew install postgresql, you have the option. - The name follows Bonjour’s UTF-8/63-byte rules, not PostgreSQL’s identifier rules. Spaces and emoji are technically legal, though doing this to your coworkers is impolite.
Recommendation: Leave bonjour = off. If you are running a workshop, demo, or classroom on a private network and want the convenience, set bonjour = on and bonjour_name = 'whatever-you-want', knowing that you are advertising a database server to everything on the local segment. This is one of those parameters whose continued existence in the GUC list is a small monument to PostgreSQL’s commitment to not removing things — the same commitment that keeps array_nulls and backslash_quote around.