knex: "TimeoutError: Knex: Timeout acquiring a connection" when using with Node 14
Environment
Node: 14.x <-- pretty sure this is the problem / difference
Knex version: 0.21.0 (also seen in older version) Database + version: Postgres 12 OS: Observed on macOS and Linux
Bug
-
Initially, all knex connections/queries failed (timed out). I was able to fix regular connections by upgrading
knexto0.21.0andnode-pgto version 8.x. However, running migrations usingknex migrate:latestornpx knex migrate:latestis still failing. -
Error message
TimeoutError: Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx) call?
at /<omitted>/node_modules/knex/lib/client.js:318:17
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 26
- Comments: 32 (3 by maintainers)
Update: turns out that our repository containing the migrations has a separate copy of knex/pg. Upgrading
pgto 8.x in this repository seems to have fixed things for me.I just resolved my problem. Upgrading your
knex: "^0.21.2"andpg: "^8.3.0"seem to help. Glad someone opened this issue 😄I had the same issue with Node.js 14.0.0 (latest),
knex0.21.1 (latest), andpg7.8.12. Upgradingpgto 8.0.3 fixed the issue.@Robmcmon Note that you will also get this error if the database is inaccessible for some reason (e.g. if you have a typo in the server address, your database is genuinely down, there’s a firewall blocking the connection, or you have no internet on the machine you are connecting from). Given that you are seeing this on Node 12 as well I’d suggest that it’s likely unconnected to the issue seen here.
However, you may also wish to check that you definitely have an 8.x version of node-postgres (
pg) installed (you could delete node modules and reinstall to be sure), as this seemed to fix the issue for Node 14.Hey @kibertoad - pg 8.0.3 did fix it for me - my lock file looks like this:
I will make a ticket with Keystone to get all the dependencies changed around 😃 thanks for your help!
I’m stuck on this issue for 3 days, i already tried all possible solutions on the internet and have no idea what is going on. I sent the project for other friends to test and it works normally, but to me this error persist, i have all package on last version, node, yarn and npm on last version, still i get this error.
The error is throw when trying to run a seed, inserting data in a table using Knex.
Already tried to downgrade node, pg, and knex, nothing works. Tried to change postgres config
max_connectionsandshared_buffers, nothing too.Tried to change knex
poolconfig on database config to a lot of different parameters, nothing…I don’t know what is wrong with this.
Interesting. I’m seeing this in CI for Node 12 of all things. Might be some other change in knex causing it. Does switching to older node fix it?