ERROR: database "x" is being accessed by other users — There is 1 other session using the database.
DROP/RENAME DATABASE can’t run while other sessions are connected.
Seen on:
PostgreSQL
Meaning
Your app, a GUI tool or another psql session keeps a connection open.
Common causes
- App or pool still connected
- GUI client (pgAdmin, DBeaver) open
- Another terminal session
⚡ Quick fix
- Stop the app / close clients
- PostgreSQL 13+: DROP DATABASE x WITH (FORCE)
- Terminate sessions with pg_terminate_backend
Detailed fix by platform
PostgreSQL
DROP DATABASE appdb_test WITH (FORCE);
How to diagnose
- Sessions — SELECT * FROM pg_stat_activity WHERE datname = 'x'
- Recent change — Did it start after a deploy, upgrade, or configuration change? Compare with the last working version.
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026