Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
How to kill all connections to a Postgres database
-- Accepted answer from here:
SELECT pg_terminate_backend(
FROM pg_stat_activity
WHERE pg_stat_activity.datname = '[your database name goes here]'
AND pid <> pg_backend_pid();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment