PG_ISREADY(1)
β¨ PG_ISREADY(1) β¨
okay bestie, this is pg_isready β it's the little PostgreSQL utility from the PostgreSQL 17.11 docs that tells you whether a server is up and vibing π
π NAME π
pg_isready β literally just checks the connection status of a PostgreSQL server. that's it. that's the whole job π
π¦ SYNOPSIS π¦
pg_isready [connection-option...] [option...]
so you run it, you throw some connection options at it, maybe some regular options, and it reports back πΈ
π DESCRIPTION π
pg_isready is a utility for checking the connection status of a PostgreSQL database server. and like β the whole result of the connection check comes back to you as the exit status, so pay attention to $?, okay? that's where the tea is π
β¨ 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, any connection string parameters in there will override conflicting command line options. she overrides. periodt π-hhostname,--host=hostname β specifies the host name of the machine on which the server is running. and if the value starts with a slash, it's used as the directory for the Unix-domain socket. sneaky but iconic π¦-pport,--port=port β specifies the TCP port, or the local Unix-domain socket file extension, that the server is listening on for connections. defaults to the value of thePGPORTenvironment variable or, if that's not set, to the port specified at compile time, usually5432β¨-q,--quietβ do not display the status message. so useful when you're scripting, because nobody wants extra noise in their logs π-tseconds,--timeout=seconds β the maximum number of seconds to wait when attempting connection before returning that the server is not responding. setting it to0disables the timeout entirely. default is3seconds β-Uusername,--username=username β connect to the database as the user username instead of the default π«Ά-V,--versionβ print thepg_isreadyversion and exit. bye π-?,--helpβ show help aboutpg_isreadycommand line arguments, and exit. also bye π
π₯ EXIT STATUS π₯
this is the main character section honestly, so let's go:
0β returned to the shell if the server is accepting connections normally. slay π1β returned if the server is rejecting connections (for example during startup). she's still loading π2β returned if there was no response to the connection attempt π3β returned if no attempt was made (for example due to invalid parameters). fair enough π
πΈ ENVIRONMENT πΈ
pg_isready, like most other PostgreSQL utilities, also uses the environment variables supported by libpq (see Section 32.15). iykyk π§
the environment variable PG_COLOR specifies whether to use color in diagnostic messages. possible values are always, auto and never. yes queen, aesthetic diagnostics π
π NOTES π
big one: it is not necessary to supply correct user name, password, or database name values to obtain the server status. so you don't have to get your credentials right just to vibe check the server π¦
but heads up β if incorrect values are provided, the server will log a failed connection attempt. so like, your DBA might see it. no cap π
β 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
and that's the whole page bestie, go check some servers π
π sign-off: brought to you byPostgreSQL 17.11, dated2026.PG_ISREADY(1)out. π«Ά
π¦ where this page comes from
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-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