PG_AUTOCTL SHOW URI(1)
β¨ PG_AUTOCTL SHOW URI β¨
okay bestie, welcome to pg_autoctl show uri β one of the pg_auto_failover girlies π
πΈ NAME πΈ
pg_autoctl show uri β pg_autoctl show uri
pg_autoctl show uri β show the postgres uri you use to connect to pg_auto_failover nodes π«Ά
π SYNOPSIS π
so like, this command spits out the monitor URI or the coordinator Postgres URI that your app should use to connect to Postgres:
usage: pg_autoctl show uri [ --pgdata --monitor --formation --json ]
--pgdata path to data directory
--monitor monitor uri
--formation show the coordinator uri of given formation
--json output data in the JSON format
π OPTIONS π
--pgdataβ where the Postgres node that's being managed locally lives. Defaults to the environment variablePGDATA. and like, use--monitorwhen you wanna connect to a monitor from literally anywhere, instead of the monitor URI that a local Postgres node managed withpg_autoctlis using. β¨--monitorβ the Postgres URI used to connect to the monitor. it MUST use theautoctl_nodeusername and target thepg_auto_failoverdatabase name, no cap. also you can show the Postgres URI from the monitor node itself withpg_autoctl show uri. it defaults to the value of the environment variablePG_AUTOCTL_MONITOR. π--formationβ when--formationis used, it lists the Postgres URIs of all known formations on the monitor. the way it just... hands you every formation π--jsonβ output JSON formatted data instead of a table formatted list. for the girlies who pipe things intojqπ¦
π ENVIRONMENT π
PGDATAβ Postgres directory location. can be used instead of the--pgdataoption.PG_AUTOCTL_MONITORβ Postgres URI to connect to the monitor node, can be used instead of the--monitoroption.XDG_CONFIG_HOMEβ thepg_autoctlcommand stores its configuration files in the standard placeXDG_CONFIG_HOME. See the XDG Base Directory Specification.XDG_DATA_HOMEβ thepg_autoctlcommand stores its internal states files in the standard placeXDG_DATA_HOME, which defaults to~/.local/share. See the XDG Base Directory Specification.
π EXAMPLES π
$ pg_autoctl show uri
Type | Name | Connection String
-------------+---------+-------------------------------
monitor | monitor | postgres://autoctl_node@localhost:5500/pg_auto_failover
formation | default | postgres://localhost:5502,localhost:5503,localhost:5501/demo?target_session_attrs=read-write&sslmode=prefer
$ pg_autoctl show uri --formation monitor
postgres://autoctl_node@localhost:5500/pg_auto_failover
$ pg_autoctl show uri --formation default
postgres://localhost:5503,localhost:5502,localhost:5501/demo?target_session_attrs=read-write&sslmode=prefer
$ pg_autoctl show uri --json
[
{
"uri": "postgres://autoctl_node@localhost:5500/pg_auto_failover",
"name": "monitor",
"type": "monitor"
},
{
"uri": "postgres://localhost:5503,localhost:5502,localhost:5501/demo?target_session_attrs=read-write&sslmode=prefer",
"name": "default",
"type": "formation"
}
]
π§ MULTI-HOSTS POSTGRES CONNECTION STRINGS π§
PostgreSQL since version 10 includes support for multiple hosts in its connection driver libpq, with the special target_session_attrs connection property. π₯
this multi-hosts connection string facility lets applications keep using the same stable connection string across server-side failovers. that's literally why pg_autoctl show uri uses that format. main character behavior fr fr π
π AUTHOR π
Microsoft
β COPYRIGHT β
Copyright (c) Microsoft Corporation. All rights reserved.
and that's the whole page bestie, slay π β¨
pg_auto_failover β version 2.2, dated Apr 07, 2025 ππ«Ά bye ily, go show some uris π
π¦ where this page comes from
- debian trixie: pg-auto-failover-cli 2.2-2 Β· PostgreSQL
- ubuntu questing: pg-auto-failover-cli 2.2-2
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms