Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have looked around for many questions on stackoverflow but have not found a solution yet to my problem.

I was running rails 4.0.2 on heroku with the default webrick server and it was working fine except I would intermittently get these errors:

ActiveRecord::ConnectionTimeoutError (could not obtain a database connection within 5.000 seconds (waited 5.000 seconds)):

And it would bring the whole site down for a significant period of time.

I have read from other answers that there are issues with this with rails 4.0.x so I have upgraded to rails 4.1.4 and will see if the issue continues occurring.

Any help as to what is causing this and how to fix this would be appreciated.

UPDATE

So as per heroku documentation and from what I can find from related questions, I have upgraded my heroku production webserver from webrick to unicorn with the default configurations specified here:

https://devcenter.heroku.com/articles/rails-unicorn

and also here:

https://devcenter.heroku.com/articles/concurrency-and-database-connections

I will watch and see if the issue continues to occur.

share|improve this question
    
Could possibly be running out of connections in your connection pool? Have you tried to increase that? devcenter.heroku.com/articles/… –  Damien Roche Jul 30 at 7:11
    
Also, is there any common query/activity happening around this error in your logs? –  Damien Roche Jul 30 at 7:13
    

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.