Puma, Sinatra, ActiveRecord and "could not obtain a database connection"

Tagged sinatra, puma, activerecord  Languages ruby

Getting connection errors with Puma, Sinatra and ActiveRecord?

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

Add this to your Sinatra application:

use ActiveRecord::ConnectionAdapters::ConnectionManagement