PG_ISREADY(1)
π PG_ISREADY(1): pg_isready π
okay so bestie, welcome to the PG_ISREADY(1) page from PostgreSQL 15.19 Documentation β we're doing a vibe check on a PostgreSQL server and keeping every single deet intact. π
πΈ NAME πΈ
pg_isready β check the connection status of a PostgreSQL server.
β¨ SYNOPSIS β¨
pg_isready [connection-option...] [option...]
π¦ 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. It's giving "are you alive?" but make it PostgreSQL, and the number it returns is the whole tea. π«Ά
π OPTIONS π
-d dbname,--dbname=dbnameβ specifies the name of the database to connect to. Thedbnamecan be a connection string. If so, connection string parameters will override any conflicting command line options. periodt.-h hostname,--host=hostnameβ specifies the host name of the machine on which the server is running. If the value begins with a slash, it is used as the directory for the Unix-domain socket.-p port,--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 introvert option.-t seconds,--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.-U username,--username=usernameβ connect to the database as the userusernameinstead of the default.-V,--versionβ print thepg_isreadyversion and exit.-?,--helpβ show help aboutpg_isreadycommand line arguments, and exit.
π EXIT STATUS π
pg_isready returns 0 to the shell if the server is accepting connections normally, 1 if the server is rejecting connections (for example during startup), 2 if there was no response to the connection attempt, and 3 if no attempt was made (for example due to invalid parameters). so yeah, the exit code is literally the result of the connection check. π
π 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.
π§ 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 just check the vibe, but bestie, the server will notice. π
β 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
π that's the whole page, bestie. Source/version: PostgreSQL 15.19 Β· date: 2026 Β· manual: PG_ISREADY(1). now go check that server, slay. π«Άβ¨
π¦ where this page comes from
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql15 15.19-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