2 doc/src/sgml/ref/pg_isready.sgml
3 PostgreSQL documentation
6 <refentry id="app-pg-isready">
8 <refentrytitle><application>pg_isready</application></refentrytitle>
9 <manvolnum>1</manvolnum>
10 <refmiscinfo>Application</refmiscinfo>
14 <refname>pg_isready</refname>
15 <refpurpose>check the connection status of a <productname>PostgreSQL</productname> server</refpurpose>
18 <indexterm zone="app-pg-isready">
19 <primary>pg_isready</primary>
24 <command>pg_isready</command>
25 <arg rep="repeat"><replaceable>connection-option</replaceable></arg>
26 <arg rep="repeat"><replaceable>option</replaceable></arg>
31 <refsect1 id="app-pg-isready-description">
32 <title>Description</title>
34 <application>pg_isready</application> is a utility for checking the connection
35 status of a <productname>PostgreSQL</productname> database server. The exit
36 status specifies the result of the connection check.
40 <refsect1 id="app-pg-isready-options">
41 <title>Options</title>
46 <term><option>-d <replaceable class="parameter">dbname</replaceable></></term>
47 <term><option>--dbname=<replaceable class="parameter">dbname</replaceable></></term>
50 Specifies the name of the database to connect to.
53 If this parameter contains an <symbol>=</symbol> sign or starts
54 with a valid <acronym>URI</acronym> prefix
55 (<literal>postgresql://</literal>
56 or <literal>postgres://</literal>), it is treated as a
57 <parameter>conninfo</parameter> string. See <xref
58 linkend="libpq-connstring"> for more information.
64 <term><option>-h <replaceable class="parameter">hostname</replaceable></></term>
65 <term><option>--host=<replaceable class="parameter">hostname</replaceable></></term>
68 Specifies the host name of the machine on which the
69 server is running. If the value begins
70 with a slash, it is used as the directory for the Unix-domain
77 <term><option>-p <replaceable class="parameter">port</replaceable></></term>
78 <term><option>--port=<replaceable class="parameter">port</replaceable></></term>
81 Specifies the TCP port or the local Unix-domain
82 socket file extension on which the server is listening for
83 connections. Defaults to the value of the <envar>PGPORT</envar>
84 environment variable or, if not set, to the port specified at
85 compile time, usually 5432.
91 <term><option>-q</option></term>
92 <term><option>--quiet</option></term>
95 Do not display status message. This is useful when scripting.
101 <term><option>-t <replaceable class="parameter">seconds</replaceable></></term>
102 <term><option>--timeout=<replaceable class="parameter">seconds</replaceable></></term>
105 The maximum number of seconds to wait when attempting connection before
106 returning that the server is not responding. Setting to 0 disables. The
107 default is 3 seconds.
113 <term><option>-U <replaceable class="parameter">username</replaceable></></term>
114 <term><option>--username=<replaceable class="parameter">username</replaceable></></term>
117 Connect to the database as the user <replaceable
118 class="parameter">username</replaceable> instead of the default.
124 <term><option>-V</></term>
125 <term><option>--version</></term>
128 Print the <application>pg_isready</application> version and exit.
134 <term><option>-?</></term>
135 <term><option>--help</></term>
138 Show help about <application>pg_isready</application> command line
147 <title>Exit Status</title>
150 <application>pg_isready</application> returns <literal>0</literal> to the shell if the server
151 is accepting connections normally, <literal>1</literal> if the server is rejecting
152 connections (for example during startup), <literal>2</literal> if there was no response to the
153 connection attempt, and <literal>3</literal> if no attempt was made (for example due to invalid
159 <title>Environment</title>
162 <command>pg_isready</command>, like most other <productname>PostgreSQL</>
164 also uses the environment variables supported by <application>libpq</>
165 (see <xref linkend="libpq-envars">).
169 <refsect1 id="app-pg-isready-notes">
173 The options <option>--dbname</> and <option>--username</> can be used to avoid gratuitous
174 error messages in the logs, but are not necessary for proper functionality.
178 <refsect1 id="app-pg-isready-examples">
179 <title>Examples</title>
184 <prompt>$</prompt> <userinput>pg_isready</userinput>
185 <computeroutput>/tmp:5432 - accepting connections</computeroutput>
186 <prompt>$</prompt> <userinput>echo $?</userinput>
187 <computeroutput>0</computeroutput>
192 Running with connection parameters to a <productname>PostgreSQL</productname> cluster in startup:
194 <prompt>$ </prompt><userinput>pg_isready -h localhost -p 5433</userinput>
195 <computeroutput>localhost:5433 - rejecting connections</computeroutput>
196 <prompt>$</prompt> <userinput>echo $?</userinput>
197 <computeroutput>1</computeroutput>
202 Running with connection parameters to a non-responsive <productname>PostgreSQL</productname> cluster:
204 <prompt>$ </prompt><userinput>pg_isready -h someremotehost</userinput>
205 <computeroutput>someremotehost:5432 - no response</computeroutput>
206 <prompt>$</prompt> <userinput>echo $?</userinput>
207 <computeroutput>2</computeroutput>