Re: Cannot connect to postgresql on port 5432

Ron <[email protected]> Mon, 23 Dec 2019 13:39:13 -0600
Newsgroups gmane.comp.db.postgresql.admin
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--------------AB79450428208A9B04DB2076
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit


What's the value of listen_addresses?

postgres=# show listen_addresses;
  listen_addresses
------------------
  localhost
(1 row)


You probably need to edit postgresql.conf and change listen_addresses from 
'localhost' to the IP addresses they need to listen to.

And, of course, make sure the firewall allows bi-directional port 5432 
between the relevant hosts.

On 12/23/19 1:30 PM, [email protected] wrote:
>
> Hi Experts,
>
> Post installation of  PostgreSQL it is not listening on an IP, only on 
> localhost.
>
> Please suggest your inputs.
>
> *_Used below command for installations –_*
>
> *# apt-get install postgresql-12*
>
> postgres=# select version();
>
> version
>
> ------------------------------------------------------------------------------------------------------------------
>
> PostgreSQL 12.1 (Debian 12.1-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled 
> by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
>
> (1 row)
>
> *_Entries in ::: /etc/postgresql/12/main/pg_hba.conf _*
>
> # Database administrative login by Unix domain socket
>
> local   all postgres                                peer
>
> # TYPE  DATABASE USER            ADDRESS                 METHOD
>
> # "local" is for Unix domain socket connections only
>
> local   all all                                     peer
>
> # IPv4 local connections:
>
> host    all all             127.0.0.1/32            md5
>
> # IPv6 local connections:
>
> host    all all             ::1/128                 md5
>
> # Allow replication connections from localhost, by a user with the
>
> # replication privilege.
>
> local   replication all                                     peer
>
> host    replication all             127.0.0.1/32            md5
>
> host    replication all             ::1/128                 md5
>
> *_Not connected_*
>
> *__*
>
> *postgres@srv:/opt$ netstat -nlp | grep 5432*
>
> (Not all processes could be identified, non-owned process info
>
> will not be shown, you would have to be root to see it all.)
>
> tcp        0      0 127.0.0.1:5432          0.0.0.0:*               LISTEN 
> 25857/postgres
>
> unix  2      [ ACC ] STREAM     LISTENING     74234    25857/postgres 
> /var/run/postgresql/.s.PGSQL.5432
>
> *postgres@srv:~$ telnet 10.133.214.32 5432*
>
> Trying 10.133.214.32...
>
> telnet: Unable to connect to remote host: Connection refused
>

-- 
Angular momentum makes the world go 'round.

--------------AB79450428208A9B04DB2076
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: 8bit

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <br>
    What's the value of listen_addresses?<br>
    <br>
    <tt>postgres=# show listen_addresses;</tt><tt><br>
    </tt><tt> listen_addresses </tt><tt><br>
    </tt><tt>------------------</tt><tt><br>
    </tt><tt> localhost</tt><tt><br>
    </tt><tt>(1 row)</tt><tt><br>
    </tt><br>
    <br>
    You probably need to edit postgresql.conf and change
    listen_addresses from 'localhost' to the IP addresses they need to
    listen to.<br>
    <br>
    And, of course, make sure the firewall allows bi-directional port
    5432 between the relevant hosts.<br>
    <br>
    <div class="moz-cite-prefix">On 12/23/19 1:30 PM,
      <a class="moz-txt-link-abbreviated" href="mailto:[email protected]">[email protected]</a> wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:2A91BEF8171A5349931391E0C721CC537D772EF8@CPEMS-KPN501.KPNCNL.LOCAL">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <meta name="Generator" content="Microsoft Word 15 (filtered
        medium)">
      <style><!--
/* Font Definitions */
@font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0cm;
	margin-bottom:.0001pt;
	font-size:11.0pt;
	font-family:"Calibri",sans-serif;
	mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:#0563C1;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{mso-style-priority:99;
	color:#954F72;
	text-decoration:underline;}
span.EmailStyle17
	{mso-style-type:personal-compose;
	font-family:"Calibri",sans-serif;
	color:windowtext;}
.MsoChpDefault
	{mso-style-type:export-only;
	font-family:"Calibri",sans-serif;
	mso-fareast-language:EN-US;}
@page WordSection1
	{size:612.0pt 792.0pt;
	margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
	{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
      <div class="WordSection1">
        <p class="MsoNormal">Hi Experts,<o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal">Post installation of  PostgreSQL it is not
          listening on an IP, only on localhost.<o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal">Please suggest your inputs.<o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal"><span
style="font-size:11.5pt;font-family:&quot;Arial&quot;,sans-serif;color:#1D1C1D;background:#F8F8F8"
            lang="EN-GB"><o:p> </o:p></span></p>
        <p class="MsoNormal"><b><u><span lang="EN-GB">Used below command
                for installations –<o:p></o:p></span></u></b></p>
        <p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
        <p class="MsoNormal"><b><span lang="EN-GB"># apt-get install
              postgresql-12<o:p></o:p></span></b></p>
        <p class="MsoNormal"><span lang="EN-GB">postgres=# select
            version();<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-GB">                                                    
            version<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-GB">------------------------------------------------------------------------------------------------------------------<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-GB">PostgreSQL 12.1 (Debian
            12.1-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc
            (Debian 8.3.0-6) 8.3.0, 64-bit<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-GB">(1 row)<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
        <p class="MsoNormal"><b><u><span lang="EN-GB">Entries in :::
                /etc/postgresql/12/main/pg_hba.conf
                <o:p></o:p></span></u></b></p>
        <p class="MsoNormal"><span lang="EN-GB"># Database
            administrative login by Unix domain socket<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-GB">local   all            
            postgres                                peer<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-GB"># TYPE  DATABASE       
            USER            ADDRESS                 METHOD<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-GB"># "local" is for Unix
            domain socket connections only<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-GB">local   all            
            all                                     peer<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-GB"># IPv4 local
            connections:<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-GB">host    all            
            all             127.0.0.1/32            md5<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-GB"># IPv6 local
            connections:<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-GB">host    all            
            all             ::1/128                 md5<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-GB"># Allow replication
            connections from localhost, by a user with the<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-GB"># replication privilege.<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-GB">local   replication    
            all                                     peer<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-GB">host    replication    
            all             127.0.0.1/32            md5<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-GB">host    replication    
            all             ::1/128                 md5<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
        <p class="MsoNormal"><b><u><span lang="EN-GB">Not connected<o:p></o:p></span></u></b></p>
        <p class="MsoNormal"><b><u><span lang="EN-GB"><o:p><span
                    style="text-decoration:none"> </span></o:p></span></u></b></p>
        <p class="MsoNormal"><b>postgres@srv:/opt$ netstat -nlp | grep
            5432<o:p></o:p></b></p>
        <p class="MsoNormal"><span lang="EN-GB">(Not all processes could
            be identified, non-owned process info<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-GB">will not be shown, you
            would have to be root to see it all.)<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-GB">tcp        0      0
            127.0.0.1:5432          0.0.0.0:*               LISTEN     
            25857/postgres<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-GB">unix  2      [ ACC ]    
            STREAM     LISTENING     74234    25857/postgres      
            /var/run/postgresql/.s.PGSQL.5432<o:p></o:p></span></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal"><b><span lang="EN-GB">postgres@srv:~$
              telnet 10.133.214.32 5432<o:p></o:p></span></b></p>
        <p class="MsoNormal"><span lang="EN-GB">Trying 10.133.214.32...<o:p></o:p></span></p>
        <p class="MsoNormal"><span lang="EN-GB">telnet: Unable to
            connect to remote host: Connection refused<o:p></o:p></span></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
      </div>
    </blockquote>
    <br>
    <div class="moz-signature">-- <br>
      Angular momentum makes the world go 'round.</div>
  </body>
</html>

--------------AB79450428208A9B04DB2076--