Skip to content

Instantly share code, notes, and snippets.

@x4b1
Created January 19, 2022 07:58
Show Gist options
  • Save x4b1/fc8bc4c77763ab0207ddf62fc74d12b3 to your computer and use it in GitHub Desktop.
Save x4b1/fc8bc4c77763ab0207ddf62fc74d12b3 to your computer and use it in GitHub Desktop.
close all pg connections
SELECT pg_terminate_backend(pg_stat_activity.pid)
FROM pg_stat_activity
WHERE pg_stat_activity.datname = 'TARGET_DB' -- ← change this to your DB
AND pid <> pg_backend_pid();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment