cancel
Showing results for 
Search instead for 
Did you mean: 

Solution for "FATAL: database "postgres" is not currently accepting connections"

Symptoms

 

$ /usr/local/pgsql/bin/psql
  psql: FATAL: database "postgres" is not currently accepting connections

 

Diagnosis

 

 The connections are disabled to the database using command alter database "postgres" with allow_connections false;. If anyone tries to connect, will get the below message:

 

 FATAL: database "postgres" is not currently accepting connections

 

Solution

 

       1)  We can revert the change by connecting to the template1 database with below command:

 

            template1=#  psql template1
            template1=#  alter database "postgres" with allow_connections true;

 

       2)  If you are using EPAS, then you need to use the utility,  edb-postgres instead of postgres. If it is not possible to connect to template1 as well, you can overcome the issue by starting the database in a single user mode and performing below commands:

 

       a)  Stop the cluster

 

             $ /usr/local/pgsql/bin/pg_ctl -D /tmp/pg101 stop -mf

 

        b)  Start in a single-user mode : 

 

             { Community Postgres }  :  $  /usr/local/pgsql/bin/postgres --single -D /tmp/pg101/ template1
                          { EPAS }   :  $ /usr/edb/as10/bin/edb-postgres --single -D /usr/edb/as10/data template1

             

      PostgreSQL stand-alone backend 10.6 :  

 

           backend> alter database postgres allow_connections true;
           backend> alter database pg1 allow_connections true;
          backend> alter database pg2 allow_connections true;
          backend> alter database template1 allow_connections true;

 

                                                      Enter Control+D to exit the single-user mode.

 

        c) Start the cluster :

 

           $ /usr/local/pgsql/bin/pg_ctl -D /tmp/pg101 start

 

 

Now you should be able to connect to the database. For more information on postgres commands and single-user mode option, please see the below link:

 

https://www.postgresql.org/docs/10/app-postgres.html

Version history
Revision #:
16 of 16
Last update:
‎07-09-2019 05:31 PM
Updated by: