1.
postgres=# drop database otmstest;
ERROR: database "otmstest" is being accessed by other users
DETAIL: There are 9 other sessions using the database.
postgres=# SELECT
postgres-# pg_terminate_backend(pid)
postgres-# FROM
postgres-# pg_stat_activity
postgres-# WHERE
postgres-# -- don't kill my own connection!
postgres-# pid <> pg_backend_pid()
postgres-# -- don't kill the connections to other databases
postgres-# AND datname = 'database_name'
postgres-# ;
2. maybe restart postgres .
sudo service postgresql restart