Hi, thanks for quick reply.
As far as I understood, every time the user does some operation with database the connection counter add one until 20 is reached, then the app stops working.
So that means that there's nothing I can do by coding, right?
Also, that means that another user (for instance, a player on my game site) has to restart heroku by himself or what's done by me is enough?
First of all, your code should of course have proper resource management. Meaning you should (always) close your connection when you are finished. If you don't do this, this connection will be gone and can't be used anymore. If you have a pool of 20 database connections and you close a connection it will be returned to the pool, so it can be used for another query. If you don't close the connection properly, the connection will not be returned to the pool and your pool will have 19 database connections left.
But if you have 25 users which login at the same time, you'll already have an issue because you need 25 database connections but have only 20.