'#<ActiveRecord::ConnectionTimeoutError: could not obtain a database connection within 5.000 seconds (waited 13.570 seconds)>
I am debugging the each and every line of the code. Is this might be the reason for the occurrence of this error? If so then how can I debug the code?
Solution 1:[1]
This happens because you have too many open connections to the database.
You can wrap your code in the block which closes the connection automatically.
ActiveRecord::Base.connection_pool.with_connection do
# your code
end
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | remy727 |
