• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

1.7K
Views
Error trying to run seeds: Knex: Timeout acquiring a connection. The pool is probably full

I'm getting this error everytime i run yarn knex seed:run:

Error while executing "/home/user/path-to-the-file/my-seed.js" seed: Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx) call?

The problem is that i send the project for other people and they can run it normally, i already tried all answers about it of the internet, i don't know what to do anymore.

My database config:

const config = Object.freeze({
  client: 'pg',
  pool: {
    min: 0,
    max: 5,
    idleTimeoutMillis: 30000,
    createTimeoutMillis: 3000,
    acquireTimeoutMillis: 30000,
    reapIntervalMillis: 1000,
    createRetryIntervalMillis: 100,
    propagateCreateError: false
  },
  connection: Object.freeze({
    ...database
  })
})
  • Knex version: "^0.95.8"
  • pg version: "^8.7.1"
  • Yarn version: 1.22.11
  • Node version: 14.17.4

I already tried to downgrade pg and node, it didnt work, nothing works.

There is a issue on Knex repository saying that upgrading to latest pg solves it, but it didnt work too: https://github.com/knex/knex/issues/2820

Can someone help me?

about 3 years ago · Santiago Trujillo
2 answers
Answer question

0

One easy way to create this error is doing this:

const rows = [];
for (let i =  0; i < 10000; i++) {
  rows.push({ name : `foo  ${i}` });
}
await Promise.all(rows.map(data => knex('user').insert(data)));

There are infinite ways how to run out of connections, but most usual cases are opening too many concurrent transactions or running huge amount of parallel queries.

Best way to find out the reason why it happen is to remove parts of the problematic code until the error doesn't occur anymore and then investigate why that reduced test case fails.

One good way to see what knex is doing internally is to set DEBUG=knex:* environment variable, before running the code so that knex outputs information about queries, transactions and pool connections while code executes.

about 3 years ago · Santiago Trujillo Report

0

faced similar issued, bumped pg to 8.7.1 and it worked

also node to 16.3.1 and knex to 0.95.11

about 3 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error