I m using PostgreSQL 9.0. It hangs during shutdown. when I used pg_ctl stop it hangs and after sometime its displaying msg:

pg_ctl: server does not shut down

and when I used psql its showing:

psql: FATAL:  the database system is shutting down

and in logs its writing these msgs

 DEBUG:  postmaster received signal 15
2011-07-14 09:36:00 ETC/GMT LOG:  received smart shutdown request

Please tell me how to resolve it?


By default, pg_ctl will attempt a "smart shutdown". This shutdown will tell the system not to accept any new connections, but not shut down until existing ones have disconnected.

You probably want to use "fast" shutdown (by executing pg_ctl -m fast), which will also disconnect existing users.

For Debian (pg_ctl is not by default on $PATH):

pg_ctlcluster 9.4 main restart -m fast

A regular shutdown request will wait until all connections are terminated.

When pg_ctl stop "hangs", it means you still have open connections to the database. Shut down all applications that connect to that server and then Postgres should shut down normally.

The error "the database system is shutting down" comes from the fact that Postgres is trying to shutdown and thereofor does not allow any new connections.


When trying to identify what's going on, you can log in via psql and type:

test=> SELECT * FROM pg_stat_activity;
 datid | datname | procpid | usesysid |   usename    | application_name | client_addr | client_hostname | client_port |         backend_start         |          xact_start           |          query_start          | waiting |          current_query          
 18703 | test |    7604 |    18702 | test_sean | psql             |             |                 |          -1 | 2011-07-14 07:23:40.021921+00 |                               | 2011-07-14 07:23:46.398894+00 | f       | <IDLE>
 18703 | test |    7673 |    18702 | test_sean | psql             |             |                 |          -1 | 2011-07-14 07:24:54.507982+00 | 2011-07-14 07:25:00.102369+00 | 2011-07-14 07:25:00.102369+00 | f       | SELECT * FROM pg_stat_activity;
(2 rows)
  • 5
    That's going to be hard, since the system is in shutdown mode... – Magnus Hagander Jul 14 '11 at 8:35
  • Quite so. The above will at least give the questioner the ability to dig in at some point in the future. – Sean Jul 15 '11 at 16:28

Unless you absolutely want to use pg_ctl, why not use the following instead :

sudo /etc/init.d/postgresql-9.1 stop

The init.d scripts issues :

$SU -l postgres -c "$PGENGINE/pg_ctl stop -D '$PGDATA' -s -m fast" > /dev/null 2>&1 < /dev/null

This is a fast shutdown and performs what you need.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.