sabes
sabes

Reputation: 335

Heroku and Postgresql and Rails - too many connections error

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?

Upvotes: 6

Views: 5968

Answers (2)

Jonathan Tran
Jonathan Tran

Reputation: 15306

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.

Upvotes: 3

sabes
sabes

Reputation: 335

Apparently I was on a dev-level DB. I upgraded to Crane level production DB and everything should be fine.

Upvotes: 1

Related Questions