4 pg_isready — check the connection status of a PostgreSQL server
8 pg_isready [connection-option...] [option...]
12 pg_isready is a utility for checking the connection status of a
13 PostgreSQL database server. The exit status specifies the result of the
20 Specifies the name of the database to connect to. The dbname can
21 be a connection string. If so, connection string parameters will
22 override any conflicting command line options.
26 Specifies the host name of the machine on which the server is
27 running. If the value begins with a slash, it is used as the
28 directory for the Unix-domain socket.
32 Specifies the TCP port or the local Unix-domain socket file
33 extension on which the server is listening for connections.
34 Defaults to the value of the PGPORT environment variable or, if
35 not set, to the port specified at compile time, usually 5432.
39 Do not display status message. This is useful when scripting.
43 The maximum number of seconds to wait when attempting connection
44 before returning that the server is not responding. Setting to 0
45 disables. The default is 3 seconds.
49 Connect to the database as the user username instead of the
54 Print the pg_isready version and exit.
58 Show help about pg_isready command line arguments, and exit.
62 pg_isready returns 0 to the shell if the server is accepting
63 connections normally, 1 if the server is rejecting connections (for
64 example during startup), 2 if there was no response to the connection
65 attempt, and 3 if no attempt was made (for example due to invalid
70 pg_isready, like most other PostgreSQL utilities, also uses the
71 environment variables supported by libpq (see Section 32.15).
73 The environment variable PG_COLOR specifies whether to use color in
74 diagnostic messages. Possible values are always, auto and never.
78 It is not necessary to supply correct user name, password, or database
79 name values to obtain the server status; however, if incorrect values
80 are provided, the server will log a failed connection attempt.
86 /tmp:5432 - accepting connections
90 Running with connection parameters to a PostgreSQL cluster in startup:
91 $ pg_isready -h localhost -p 5433
92 localhost:5433 - rejecting connections
96 Running with connection parameters to a non-responsive PostgreSQL
98 $ pg_isready -h someremotehost
99 someremotehost:5432 - no response