Home Explore Blog CI



postgresql

10th chunk of `doc/src/sgml/config.sgml`
6f8ab0c36524de217cceb55c2a6f4cb01d92bd78219e05580000000100000fbd
 listen for connections from client applications.
         The value takes the form of a comma-separated list of host names
         and/or numeric IP addresses.  The special entry <literal>*</literal>
         corresponds to all available IP interfaces.  The entry
         <literal>0.0.0.0</literal> allows listening for all IPv4 addresses and
         <literal>::</literal> allows listening for all IPv6 addresses.
         If the list is empty, the server does not listen on any IP interface
         at all, in which case only Unix-domain sockets can be used to connect
         to it.  If the list is not empty, the server will start if it
         can listen on at least one TCP/IP address.  A warning will be
         emitted for any TCP/IP address which cannot be opened.
         The default value is <systemitem class="systemname">localhost</systemitem>,
         which allows only local TCP/IP <quote>loopback</quote> connections to be
         made.
       </para>
       <para>
         While client authentication (<xref
         linkend="client-authentication"/>) allows fine-grained control
         over who can access the server, <varname>listen_addresses</varname>
         controls which interfaces accept connection attempts, which
         can help prevent repeated malicious connection requests on
         insecure network interfaces.  This parameter can only be set
         at server start.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry id="guc-port" xreflabel="port">
      <term><varname>port</varname> (<type>integer</type>)
      <indexterm>
       <primary><varname>port</varname> configuration parameter</primary>
      </indexterm>
      </term>
      <listitem>
       <para>
        The TCP port the server listens on; 5432 by default.  Note that the
        same port number is used for all IP addresses the server listens on.
        This parameter can only be set at server start.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry id="guc-max-connections" xreflabel="max_connections">
      <term><varname>max_connections</varname> (<type>integer</type>)
      <indexterm>
       <primary><varname>max_connections</varname> configuration parameter</primary>
      </indexterm>
      </term>
      <listitem>
       <para>
        Determines the maximum number of concurrent connections to the
        database server. The default is typically 100 connections, but
        might be less if your kernel settings will not support it (as
        determined during <application>initdb</application>).  This parameter can
        only be set at server start.
       </para>

       <para>
        <productname>PostgreSQL</productname> sizes certain resources based directly on the value of
        <varname>max_connections</varname>. Increasing its value leads to
        higher allocation of those resources, including shared memory.
       </para>

       <para>
        When running a standby server, you must set this parameter to the
        same or higher value than on the primary server. Otherwise, queries
        will not be allowed in the standby server.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry id="guc-reserved-connections" xreflabel="reserved_connections">
      <term><varname>reserved_connections</varname> (<type>integer</type>)
      <indexterm>
       <primary><varname>reserved_connections</varname> configuration parameter</primary>
      </indexterm>
      </term>
      <listitem>
       <para>
        Determines the number of connection <quote>slots</quote> that are
        reserved for connections by roles with privileges of the
        <xref linkend="predefined-role-pg-use-reserved-connections"/>
        role.  Whenever the number of free connection slots is greater than
        <xref linkend="guc-superuser-reserved-connections"/> but less than or
        equal to the sum of <varname>superuser_reserved_connections</varname>
        and <varname>reserved_connections</varname>,

Title: PostgreSQL Connection Settings: listen_addresses, port, max_connections, and reserved_connections
Summary
This section details several key PostgreSQL connection settings. It expands on the listen_addresses parameter, explaining how to specify IP addresses for the server to listen on, including special entries like '*' for all interfaces. It then covers the port parameter, used to set the TCP port for the server. The max_connections parameter is discussed, explaining how it determines the maximum number of concurrent connections and its impact on resource allocation. Finally, reserved_connections are introduced as connection slots reserved for roles with specific privileges.