Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

2K
Visualizações
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?

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

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.

over 4 years ago · Santiago Trujillo Relatório

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

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda