pg_isready - check the connection status of a PostgreSQL server
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.
Specifies the name of the database to connect to.
If this parameter contains an
=sign or starts with a valid URI prefix (
postgres://), it is treated as a
conninfostring. See Section 34.1.1 for more information.
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.
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 the
PGPORTenvironment variable or, if not set, to the port specified at compile time, usually 5432.
Do not display status message. This is useful when scripting.
The maximum number of seconds to wait when attempting connection before returning that the server is not responding. Setting to 0 disables. The default is 3 seconds.
Connect to the database as the user
usernameinstead of the default.
Print the pg_isready version and exit.
Show help about pg_isready command line arguments, and exit.
to the shell if the server
is accepting connections normally,
if the server is rejecting
connections (for example during startup),
if there was no response to the
connection attempt, and
if no attempt was made (for example due to invalid
, like most other
also uses the environment variables supported by
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.
/tmp:5432 - accepting connections
Running with connection parameters to a PostgreSQL cluster in startup:
pg_isready -h localhost -p 5433
localhost:5433 - rejecting connections
Running with connection parameters to a non-responsive PostgreSQL cluster:
pg_isready -h someremotehost
someremotehost:5432 - no response