PG_ISREADY(1)
π pg_isready(1) β your lil vibe check for a Postgres server π
okay so bestie, this is the PG_ISREADY(1) page, straight out of the PostgreSQL 16.15 docs, and it's genuinely one of the most useful lil tools in the whole toolbox. let's get into it π«Ά
πΈ NAME πΈ
pg_isready β check the connection status of a PostgreSQL server
like, is the server up? is it down? is it going through something? pg_isready will tell you. no cap.
β¨ SYNOPSIS β¨
pg_isready [connection-option...] [option...]
that's it. that's the whole thing. you throw connection options at it, you throw regular options at it, it goes and checks. iconic behavior honestly π
π¦ DESCRIPTION π¦
pg_isready is a utility for checking the connection status of a PostgreSQL database server. The exit status specifies the result of the connection check.
and that's the whole personality: it checks, and then it tells you the answer through its exit status. so if you're scripting, you're not parsing text β you're reading $? like the main character you are. β
fr fr: the exit status is the answer. the pretty printed message is just a bonus.
π OPTIONS π
-ddbname,--dbname=dbname β Specifies the name of the database to connect to. plot twist: dbname can be a connection string, and if it is, connection string parameters will override any conflicting command line options. so the connection string wins the argument. periodt. π-hhostname,--host=hostname β Specifies the host name of the machine on which the server is running. and if the value begins with a slash, it's used as the directory for the Unix-domain socket. slash = socket, that's the trick iykyk π§-pport,--port=port β Specifies the TCP port or the local Unix-domain socket file extension on which the server is listening for connections. Defaults to the value of thePGPORTenvironment variable or, if not set, to the port specified at compile time, usually5432. β¨-q,--quietβ Do not display status message. This is useful when scripting. lowkey the move when you just want the exit code and none of the chit-chat π€«-tseconds,--timeout=seconds β The maximum number of seconds to wait when attempting connection before returning that the server is not responding. Setting to0disables. The default is3seconds. three seconds of patience, then it says what it says π-Uusername,--username=username β Connect to the database as the user username instead of the default.-V,--versionβ Print thepg_isreadyversion and exit.-?,--helpβ Show help aboutpg_isreadycommand line arguments, and exit.
π EXIT STATUS π
get ready bestie, this is the whole point of the tool. pg_isready returns:
0to the shell if the server is accepting connections normally β slay, we're so back π1if the server is rejecting connections (for example during startup) β it's waking up, give it a minute2if there was no response to the connection attempt β π3if no attempt was made (for example due to invalid parameters) β that one's on you, not the server π
π ENVIRONMENT π
pg_isready, like most other PostgreSQL utilities, also uses the environment variables supported by libpq (see Section 34.15).
The environment variable PG_COLOR specifies whether to use color in diagnostic messages. Possible values are always, auto and never. pretty messages? we love to see it π
π NOTES π
It is not necessary to supply correct user name, password, or database name values to obtain the server status; however, if incorrect values are provided, the server will log a failed connection attempt.
so like β you can be messy and pass garbage credentials and still get your answer, but the server's log will remember. it always remembers. π
π EXAMPLES π
π« Standard Usage
$ pg_isready
/tmp:5432 - accepting connections
$ echo $?
0
π« Running with connection parameters to a PostgreSQL cluster in startup
$ pg_isready -h localhost -p 5433
localhost:5433 - rejecting connections
$ echo $?
1
π« Running with connection parameters to a non-responsive PostgreSQL cluster
$ pg_isready -h someremotehost
someremotehost:5432 - no response
$ echo $?
2
see? three examples, three exit codes, all the vibes. π¦
and that's the tea, bestie π«Ά this lil page came to you courtesy of PostgreSQL 16.15, dated 2026, under the manual name PG_ISREADY(1) β go check on your servers, they miss you β¨ππ
π¦ where this page comes from
- opensuse-leap 16.0: postgresql16 16.15-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql16 16.15-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql16 16.15-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql16 16.15-160000.1.1 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms