Postgressql: cannot drop the currently open database

Delete database error:

pq: cannot drop the currently open database

Solutions:

SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE datname='database-name' AND pid<>pg_backend_pid();

Kill the PID process
 
Then use super administrator to execute:
DROP DATABASE ‘database-name’

Read More: