How to list active connections on PostgreSQL?

Tregoreg picture Tregoreg · Dec 12, 2014 · Viewed 168.8k times · Source

Is there a command in PostgreSQL to select active connections to a given database?

psql states that I can't drop one of my databases because there are active connections to it, so I would like to see what the connections are (and from which machines)

Answer

Tregoreg picture Tregoreg · Dec 12, 2014

Oh, I just found that command on PostgreSQL forum:

SELECT * FROM pg_stat_activity;