User has exceeded the ‘max_user_connections’ resource error in Heroku

Today morning, after changing my codes I pushed the changes to production only to find out that my app is crashing.

When I checked the logs all I found is that:

Mysql2::Error (User ‘xxxxxxxx’ has exceeded the ‘max_user_connections’ resource (current value: 15)).

I am using ClearDB addon to connect Mysql in Heroku.

Also I am using unicorn as a web server for my application, which is running multiple dynos.

I ran up to find the solutions of this issue and I came across the article which gave me relief.

Here is the link to it: http://goo.gl/DSdvTu

I have made changes to get rid of Bad connections error which was happening because some of the queries are taking so much times that they are eventually timing out. They are eating up the resources of DB.

Steps to fix-

– Modify the queries

– Add indices to tables and double-check to confirm

– Change unicorn.rb

Hope this will help you too.

Contact me for further assistance.