What limits the number of connections?
First of all, the GUC max_connections - a setting in postgresql.conf. It can only be set at server start.
Heroku obviously limits this to 20 for the &quot;Starter Tier&quot; and 500 for the &quot;Production Tier&quot;.
The maximum number is not limited by Postgres itself, but by available system resources. Typically, performance degrades with too many concurrent connections, so even if you can set max_connections = 1000, it's probably unwise. Idle sessions don't matter much. But concurrently active sessions compete for resources, the bottleneck typically being I/O.
Here is a blog with instructions by someone who did.