Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx) call?

System Information
  • Strapi v4.1.11:
  • Ubuntu:
  • PostgreSQL:
  • Node v14.19.2:
  • NPM v6.14.17:
  • Yarn Version:

I followed this guide for deploying my strapi backend on an AWS instance and when trying to run get this error:

Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx) call?

I’ve tried all the tweaks I found online from changing the db inbound rules to allowing all traffic from my IP to adding different pool configurations to my database.js file. Nothing works.

Has anyone been able to find a workaround?

Try adding a large value to acquireConnectionTime to database config.
Example:

module.exports = ({ env }) => ({
connection: {
client: ‘postgres’,
connection: {
host: env(‘DATABASE_HOST’, ‘127.0.0.1’),
port: env.int(‘DATABASE_PORT’, 5432),
database: env(‘DATABASE_NAME’, ‘strapi’),
user: env(‘DATABASE_USERNAME’, ‘strapi’),
password: env(‘DATABASE_PASSWORD’, ‘strapi’),
schema: env(‘DATABASE_SCHEMA’, ‘public’), // Not required
ssl: env(‘DATABASE_SSL’, false)
},
acquireConnectionTimeout: 1000000,
pool: {
min: 0,
max: 1,
acquireTimeoutMillis: 300000,
createTimeoutMillis: 300000,
destroyTimeoutMillis: 300000,
idleTimeoutMillis: 30000,
reapIntervalMillis:1000,
createRetryIntervalMillis: 2000
},
debug: false,
},
});