title: connection to server at "localhost" , port 5432 failed: Connection refused Is the server running on that host and accepting TCP/IP connections?
body: <p>I am doing a project using django rest framework. It was working ok, but at the moment I am getting error</p>
  <pre><code>connection to server at &quot;localhost&quot;(127.0.0.1), port 5432 failed:  
  Connection refused Is the server running on that host and accepting TCP/IP connections?
  </code></pre>
  <p>I knew that the problem with postgresql. Because I've tried to connect it with pgadmin, and also gives me this error.<br />
  I am using Ubuntu OS, when I checked ubuntu not listening port 5432.</p>
  <p><strong>postgresql.conf</strong></p>
  <pre><code># - Connection Settings -
  
  listen_addresses = '*'          # what IP address(es) to listen on;
                                          # comma-separated list of addresses;
                                          # defaults to 'localhost'; use '*' for &gt;
                                          # (change requires restart)
  port = 5432                             # (change requires restart)
  max_connections = 100                   # (change requires restart)
  #superuser_reserved_connections = 3     # (change requires restart)
  #unix_socket_directories = '/var/run/postgresql'        # comma-separated list &gt;
                                          # (change requires restart)
  </code></pre>
  <p>When I run <code>service postgresql status</code>, it says following.</p>
  <pre><code>● postgresql.service - PostgreSQL RDBMS
       Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor pr&gt;
       Active: active (exited) since Tue 2022-05-17 09:22:03 +05; 1h 9min ago
      Process: 6270 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
     Main PID: 6270 (code=exited, status=0/SUCCESS)
  
  May 17 09:22:03 mirodil-vivobook systemd[1]: Starting PostgreSQL RDBMS...
  May 17 09:22:03 mirodil-vivobook systemd[1]: Finished PostgreSQL RDBMS.
  
  </code></pre>
  <p>Here is the outpu of the <code>ss -nlt</code>:</p>
  <pre><code>State   Recv-Q   Send-Q     Local Address:Port      Peer Address:Port  Process  
  LISTEN  0        511            127.0.0.1:40915          0.0.0.0:*              
  LISTEN  0        4096       127.0.0.53%lo:53             0.0.0.0:*              
  LISTEN  0        5              127.0.0.1:631            0.0.0.0:*              
  LISTEN  0        4096           127.0.0.1:9050           0.0.0.0:*              
  LISTEN  0        5              127.0.0.1:39261          0.0.0.0:*              
  LISTEN  0        5                0.0.0.0:35587          0.0.0.0:*              
  LISTEN  0        128              0.0.0.0:25672          0.0.0.0:*              
  LISTEN  0        511            127.0.0.1:6379           0.0.0.0:*              
  LISTEN  0        511                    *:80                   *:*              
  LISTEN  0        4096                   *:4369                 *:*              
  LISTEN  0        5                  [::1]:631               [::]:*              
  LISTEN  0        511                    *:35711                *:*              
  LISTEN  0        128                    *:5672                 *:*              
  LISTEN  0        511                [::1]:6379              [::]:* 
  </code></pre>
  <p>Seems something caused blocked 5432 port. How to solve this problem ?</p>
  <p><strong>postgresql.log</strong><br />
  <a href="https://i.stack.imgur.com/dz3Ew.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dz3Ew.png" alt="enter image description here" /></a></p>