I'm getting the following error with Ruby on Rails, Heroku and Postgresql:
PG::Error (FATAL: too many connections for role "********"
I've restarted the server several times to no avail. Any ideas?
Heroku provides managed Postgres databases. Different tiered databases have different connection limits. The Hobby Tier databases are limited to 20 connections. Standard and higher tier databases have higher limits.
PostgreSQL Connection Limits At provision, Databases for PostgreSQL sets the maximum number of connections to your PostgreSQL database to 115. 15 connections are reserved for the superuser to maintain the state and integrity of your database, and 100 connections are available for you and your applications.
Paying Heroku more money isn't always the answer.
I had this problem temporarily when I was running up against the dev-level database's row limit. Deleting rows using the console until I was below the limit solved the issue.
Another potential way you can run into this is if you're using unicorn. The number of connections used is the number of dynos times the number of unicorn workers per dyno. Heroku explains it all here, along with a way to configure it in config/unicorn.rb
.
Also, seeing the number of connections being used can be useful. Just run heroku pg:info
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With