]> begriffs open source - ai-pg/blob - full-docs/src/sgml/html/app-pg-isready.html
PG 18 docs from https://ftp.postgresql.org/pub/source/v18.0/postgresql-18.0-docs...
[ai-pg] / full-docs / src / sgml / html / app-pg-isready.html
1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>pg_isready</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="app-pg-dumpall.html" title="pg_dumpall" /><link rel="next" href="app-pgreceivewal.html" title="pg_receivewal" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center"><span class="application">pg_isready</span></th></tr><tr><td width="10%" align="left"><a accesskey="p" href="app-pg-dumpall.html" title="pg_dumpall">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="reference-client.html" title="PostgreSQL Client Applications">Up</a></td><th width="60%" align="center">PostgreSQL Client Applications</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 18.0 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="app-pgreceivewal.html" title="pg_receivewal">Next</a></td></tr></table><hr /></div><div class="refentry" id="APP-PG-ISREADY"><div class="titlepage"></div><a id="id-1.9.4.16.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle"><span class="application">pg_isready</span></span></h2><p>pg_isready — check the connection status of a <span class="productname">PostgreSQL</span> server</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p id="id-1.9.4.16.4.1"><code class="command">pg_isready</code> [<em class="replaceable"><code>connection-option</code></em>...] [<em class="replaceable"><code>option</code></em>...]</p></div></div><div class="refsect1" id="APP-PG-ISREADY-DESCRIPTION"><h2>Description</h2><p>
3    <span class="application">pg_isready</span> is a utility for checking the connection
4    status of a <span class="productname">PostgreSQL</span> database server. The exit
5    status specifies the result of the connection check.
6   </p></div><div class="refsect1" id="APP-PG-ISREADY-OPTIONS"><h2>Options</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-d <em class="replaceable"><code>dbname</code></em></code><br /></span><span class="term"><code class="option">--dbname=<em class="replaceable"><code>dbname</code></em></code></span></dt><dd><p>
7        Specifies the name of the database to connect to. The
8        <em class="replaceable"><code>dbname</code></em> can be a <a class="link" href="libpq-connect.html#LIBPQ-CONNSTRING" title="32.1.1. Connection Strings">connection string</a>.  If so,
9        connection string parameters will override any conflicting command
10        line options.
11       </p></dd><dt><span class="term"><code class="option">-h <em class="replaceable"><code>hostname</code></em></code><br /></span><span class="term"><code class="option">--host=<em class="replaceable"><code>hostname</code></em></code></span></dt><dd><p>
12        Specifies the host name of the machine on which the
13        server is running. If the value begins
14        with a slash, it is used as the directory for the Unix-domain
15        socket.
16        </p></dd><dt><span class="term"><code class="option">-p <em class="replaceable"><code>port</code></em></code><br /></span><span class="term"><code class="option">--port=<em class="replaceable"><code>port</code></em></code></span></dt><dd><p>
17        Specifies the TCP port or the local Unix-domain
18        socket file extension on which the server is listening for
19        connections. Defaults to the value of the <code class="envar">PGPORT</code>
20        environment variable or, if not set, to the port specified at
21        compile time, usually 5432.
22        </p></dd><dt><span class="term"><code class="option">-q</code><br /></span><span class="term"><code class="option">--quiet</code></span></dt><dd><p>
23         Do not display status message. This is useful when scripting.
24        </p></dd><dt><span class="term"><code class="option">-t <em class="replaceable"><code>seconds</code></em></code><br /></span><span class="term"><code class="option">--timeout=<em class="replaceable"><code>seconds</code></em></code></span></dt><dd><p>
25         The maximum number of seconds to wait when attempting connection before
26         returning that the server is not responding. Setting to 0 disables. The
27         default is 3 seconds.
28        </p></dd><dt><span class="term"><code class="option">-U <em class="replaceable"><code>username</code></em></code><br /></span><span class="term"><code class="option">--username=<em class="replaceable"><code>username</code></em></code></span></dt><dd><p>
29        Connect to the database as the user <em class="replaceable"><code>username</code></em> instead of the default.
30        </p></dd><dt><span class="term"><code class="option">-V</code><br /></span><span class="term"><code class="option">--version</code></span></dt><dd><p>
31          Print the <span class="application">pg_isready</span> version and exit.
32         </p></dd><dt><span class="term"><code class="option">-?</code><br /></span><span class="term"><code class="option">--help</code></span></dt><dd><p>
33         Show help about <span class="application">pg_isready</span> command line
34         arguments, and exit.
35        </p></dd></dl></div></div><div class="refsect1" id="id-1.9.4.16.7"><h2>Exit Status</h2><p>
36    <span class="application">pg_isready</span> returns <code class="literal">0</code> to the shell if the server
37    is accepting connections normally, <code class="literal">1</code> if the server is rejecting
38    connections (for example during startup), <code class="literal">2</code> if there was no response to the
39    connection attempt, and <code class="literal">3</code> if no attempt was made (for example due to invalid
40    parameters).
41   </p></div><div class="refsect1" id="id-1.9.4.16.8"><h2>Environment</h2><p>
42    <code class="command">pg_isready</code>, like most other <span class="productname">PostgreSQL</span>
43    utilities,
44    also uses the environment variables supported by <span class="application">libpq</span>
45    (see <a class="xref" href="libpq-envars.html" title="32.15. Environment Variables">Section 32.15</a>).
46   </p><p>
47    The environment variable <code class="envar">PG_COLOR</code> specifies whether to use
48    color in diagnostic messages. Possible values are
49    <code class="literal">always</code>, <code class="literal">auto</code> and
50    <code class="literal">never</code>.
51   </p></div><div class="refsect1" id="APP-PG-ISREADY-NOTES"><h2>Notes</h2><p>
52    It is not necessary to supply correct user name, password, or database
53    name values to obtain the server status; however, if incorrect values
54    are provided, the server will log a failed connection attempt.
55   </p></div><div class="refsect1" id="APP-PG-ISREADY-EXAMPLES"><h2>Examples</h2><p>
56    Standard Usage:
57 </p><pre class="screen">
58 <code class="prompt">$</code> <strong class="userinput"><code>pg_isready</code></strong>
59 <code class="computeroutput">/tmp:5432 - accepting connections</code>
60 <code class="prompt">$</code> <strong class="userinput"><code>echo $?</code></strong>
61 <code class="computeroutput">0</code>
62 </pre><p>
63   </p><p>
64    Running with connection parameters to a <span class="productname">PostgreSQL</span> cluster in startup:
65 </p><pre class="screen">
66 <code class="prompt">$ </code><strong class="userinput"><code>pg_isready -h localhost -p 5433</code></strong>
67 <code class="computeroutput">localhost:5433 - rejecting connections</code>
68 <code class="prompt">$</code> <strong class="userinput"><code>echo $?</code></strong>
69 <code class="computeroutput">1</code>
70 </pre><p>
71   </p><p>
72    Running with connection parameters to a non-responsive <span class="productname">PostgreSQL</span> cluster:
73 </p><pre class="screen">
74 <code class="prompt">$ </code><strong class="userinput"><code>pg_isready -h someremotehost</code></strong>
75 <code class="computeroutput">someremotehost:5432 - no response</code>
76 <code class="prompt">$</code> <strong class="userinput"><code>echo $?</code></strong>
77 <code class="computeroutput">2</code>
78 </pre><p>
79   </p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="app-pg-dumpall.html" title="pg_dumpall">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="reference-client.html" title="PostgreSQL Client Applications">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="app-pgreceivewal.html" title="pg_receivewal">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="application">pg_dumpall</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 18.0 Documentation">Home</a></td><td width="40%" align="right" valign="top"> <span class="application">pg_receivewal</span></td></tr></table></div></body></html>