Why can't we increase database connection limits on Postgres

Issue

A customer on a large enough Postgres plan to have 500 connections as the limit would like us to increase it further. We can't increase this limit, but we have some guidance and generally suggest using pgBouncer in this case.

Resolution

Unfortunately, we don't provide the option to increase connection limits on database plans. You can read our post on connection limit guidance to get some context on the limits.

If your app uses too many connection you will see FATAL: remaining connection slots are reserved for non-replication superuser connections in your logs. If an app has a chronic connection count issue it should use a connection pooler like pgBouncer which we offer on Postgres servers.

heroku pg:ps <database> is a useful customer-facing tool for seeing where connections are originating. In that output will be the pid of the connection and you can use heroku pg:kill <pid> to terminate that backend. There is also heroku pg:killall if you'd like to terminate all connections and let your app re-establish them.

A known "gotcha" for connections is that when deploying applications with preboot enabled, the connection count will be temporarily doubled. This is because both sets of dynos will be running at the same time and making connections.

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