What is using up my Postgres connections?

Issue

Postgres connections are being used and you want to determine the source.

Resolution

You can query the internal pg_stat_activity Postgres view to find more details on the active connections:

$ heroku pg:psql -c 'select usename, application_name, backend_start, query, wait_event, backend_type from pg_stat_activity;' --app my-app-name

This may show connections from Heroku health checks (Heroku+Postgres+-+Automation) and Postgres internal processes such as: high-availability standby replication, autovacuum worker, pglogical supervisor, WAL writer, checkpointer, background writer, etc.

Note: The field backend_type in the previous query will only work in PostgreSQL version 10 and above. Remove this field for previous versions.

Ask on Stack Overflow

Engage with a community of passionate experts to get the answers you need

Ask on Stack Overflow

Heroku Support

Create a support ticket and our support experts will get back to you

Contact Heroku Support