1PG_ISREADY(1) PostgreSQL 10.7 Documentation PG_ISREADY(1)
2
3
4
6 pg_isready - check the connection status of a PostgreSQL server
7
9 pg_isready [connection-option...] [option...]
10
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
14 connection check.
15
17 -d dbname
18 --dbname=dbname
19 Specifies the name of the database to connect to.
20
21 If this parameter contains an = sign or starts with a valid URI
22 prefix (postgresql:// or postgres://), it is treated as a conninfo
23 string. See Section 33.1.1 for more information.
24
25 -h hostname
26 --host=hostname
27 Specifies the host name of the machine on which the server is
28 running. If the value begins with a slash, it is used as the
29 directory for the Unix-domain socket.
30
31 -p port
32 --port=port
33 Specifies the TCP port or the local Unix-domain socket file
34 extension on which the server is listening for connections.
35 Defaults to the value of the PGPORT environment variable or, if not
36 set, to the port specified at compile time, usually 5432.
37
38 -q
39 --quiet
40 Do not display status message. This is useful when scripting.
41
42 -t seconds
43 --timeout=seconds
44 The maximum number of seconds to wait when attempting connection
45 before returning that the server is not responding. Setting to 0
46 disables. The default is 3 seconds.
47
48 -U username
49 --username=username
50 Connect to the database as the user username instead of the
51 default.
52
53 -V
54 --version
55 Print the pg_isready version and exit.
56
57 -?
58 --help
59 Show help about pg_isready command line arguments, and exit.
60
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
66 parameters).
67
69 pg_isready, like most other PostgreSQL utilities, also uses the
70 environment variables supported by libpq (see Section 33.14).
71
73 It is not necessary to supply correct user name, password, or database
74 name values to obtain the server status; however, if incorrect values
75 are provided, the server will log a failed connection attempt.
76
78 Standard Usage:
79
80 $ pg_isready
81 /tmp:5432 - accepting connections
82 $ echo $?
83 0
84
85 Running with connection parameters to a PostgreSQL cluster in startup:
86
87 $ pg_isready -h localhost -p 5433
88 localhost:5433 - rejecting connections
89 $ echo $?
90 1
91
92 Running with connection parameters to a non-responsive PostgreSQL
93 cluster:
94
95 $ pg_isready -h someremotehost
96 someremotehost:5432 - no response
97 $ echo $?
98 2
99
100
101
102
103
104PostgreSQL 10.7 2019 PG_ISREADY(1)