mingxi
February 3, 2021, 1:00pm
1
Hi guys, I have a problem on Herku:
What’s the problem? - Does it have to do with the fact that my Strapi on Heroku only has the
Hobby Dyno Type ?
Thanks in advance!
There have been a few times this question has come up:
opened 10:57PM - 19 Dec 20 UTC
closed 04:48AM - 20 Dec 20 UTC
<!--
Hello 👋 Thank you for submitting an issue.
Before you start, please mak… e sure your issue is understandable and reproducible.
To make your issue readable make sure you use valid Markdown syntax.
https://guides.github.com/features/mastering-markdown/
Please ensure you have also read and understand the contributing guide.
https://github.com/strapi/strapi/blob/master/CONTRIBUTING.md#reporting-an-issue
-->
## Bug report
### Describe the bug
0|strapi | [2020-12-19T22:56:19.076Z] debug ⛔️ Server wasn't able to start properly.
0|strapi | [2020-12-19T22:56:19.080Z] error KnexTimeoutError: Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx) call?
0|strapi | at Client_PG.acquireConnection (/home/ubuntu/strapi/node_modules/knex/lib/client.js:348:26)
### Steps to reproduce the behavior
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
### Expected behavior
A clear and concise description of what you expected to happen.
### Screenshots
If applicable, add screenshots to help explain your problem.
### Code snippets
If applicable, add code samples to help explain your problem.
### System
- Node.js version:
- NPM version:
- Strapi version:
- Database:
- Operating system:
### Additional context
Add any other context about the problem here.
opened 02:49PM - 06 Oct 20 UTC
closed 02:45PM - 15 Oct 20 UTC
type: help wanted
**Describe the bug**
Constantly getting Knex timeout error, on Heroku. This was… happening on and off with all my strapi deployments on Heroku, which is either using MySQL or Postgres. I have googled quite a fair bit, but still, can't able to figure out what's happening.
Full log:
```
[2020-10-06T14:35:50.827Z] error KnexTimeoutError: Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx) call?
Oct 06 07:35:51 cms app/web.1 at Client_MySQL.acquireConnection (/app/node_modules/knex/lib/client.js:349:26)
Oct 06 07:35:51 cms app/web.1 at runNextTicks (internal/process/task_queues.js:58:5)
Oct 06 07:35:51 cms app/web.1 at listOnTimeout (internal/timers.js:523:9)
Oct 06 07:35:51 cms app/web.1 at processTimers (internal/timers.js:497:7)
Oct 06 07:35:51 cms app/web.1 at async Promise.all (index 0)
Oct 06 07:35:51 cms app/web.1 at async createOrUpdateTable (/app/node_modules/strapi-connector-bookshelf/lib/build-database-schema.js:172:26)
Oct 06 07:35:51 cms app/web.1 at async module.exports (/app/node_modules/strapi-connector-bookshelf/lib/build-database-schema.js:402:9)
Oct 06 07:35:51 cms app/web.1 at async /app/node_modules/strapi-connector-bookshelf/lib/mount-models.js:618:7
Oct 06 07:35:51 cms app/web.1 at async Promise.all (index 1)
Oct 06 07:35:51 cms app/web.1 at async Promise.all (index 1)
Oct 06 07:35:51 cms app/web.1 at async Promise.all (index 0)
Oct 06 07:35:51 cms app/web.1 at async Object.initialize (/app/node_modules/strapi-database/lib/connector-registry.js:30:9)
Oct 06 07:35:51 cms app/web.1 at async DatabaseManager.initialize (/app/node_modules/strapi-database/lib/database-manager.js:36:5)
Oct 06 07:35:51 cms app/web.1 at async Strapi.load (/app/node_modules/strapi/lib/Strapi.js:308:5)
Oct 06 07:35:51 cms app/web.1 at async Strapi.start (/app/node_modules/strapi/lib/Strapi.js:190:9)
```
**Steps to reproduce the behavior**
`npm start` on Heroku. I have updated my database config as follows:
```
{
defaultConnection: "default",
connections: {
default: {
connector: "bookshelf",
settings: {
client: "mysql",
host: env("DATABASE_HOST", process.env.DATABASE_HOST),
port: env.int("DATABASE_PORT", process.env.DATABASE_PORT),
database: env("DATABASE_NAME", process.env.DATABASE_NAME),
username: env("DATABASE_USERNAME", process.env.DATABASE_USERNAME),
password: env("DATABASE_PASSWORD", process.env.DATABASE_PASSWORD),
schema: "public",
ssl: true,
},
options: {
debug: false,
pool: {
min: 2,
max: 10,
createTimeoutMillis: 30000,
acquireTimeoutMillis: 30000,
idleTimeoutMillis: 30000,
reapIntervalMillis: 30000,
createRetryIntervalMillis: 30000,
propagateCreateError: false,
},
},
},
},
};
```
**System**
- Node.js version: 14.13.0
- NPM version: 6.14.8
- Strapi version: Strapi: 3.1.7
- Database: mysql": "^2.18.1"
- "knex": "^0.21.6",
- Operating system: Linux
**Additional context**
This issue is not there initially with a fresh deployment, but over time I see this issue happening. Not really any pattern, there is not a lot of data as well.
Any help will be really appreciated 👍
Cheers,
Jeremy
Reference Issue in Knex: https://github.com/knex/knex/issues/2820
opened 04:38AM - 26 Feb 20 UTC
closed 03:23PM - 08 Apr 20 UTC
type: help wanted
**Describe the bug**
I followed the migration guide here: https://strapi.io/doc… umentation/3.0.0-beta.x/migration-guide/migration-guide-beta.17-to-beta.18.html
However, I'm getting a generic error that seems to say I cannot connect to my datasource.
```
[2020-02-26T04:11:31.633Z] error Migration failed
[2020-02-26T04:11:31.635Z] error TimeoutError: Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx) call?
at C:\Users\njste\code\experience-engine\platform\node_modules\knex\lib\client.js:348:17
at tryCatcher (C:\Users\njste\code\experience-engine\platform\node_modules\bluebird\js\release\util.js:16:23)
at C:\Users\njste\code\experience-engine\platform\node_modules\bluebird\js\release\catch_filter.js:17:41
at tryCatcher (C:\Users\njste\code\experience-engine\platform\node_modules\bluebird\js\release\util.js:16:23)
at Promise._settlePromiseFromHandler (C:\Users\njste\code\experience-engine\platform\node_modules\bluebird\js\release\promise.js:547:31)
at Promise._settlePromise (C:\Users\njste\code\experience-engine\platform\node_modules\bluebird\js\release\promise.js:604:18)
at Promise._settlePromise0 (C:\Users\njste\code\experience-engine\platform\node_modules\bluebird\js\release\promise.js:649:10)
at Promise._settlePromises (C:\Users\njste\code\experience-engine\platform\node_modules\bluebird\js\release\promise.js:725:18)
at _drainQueueStep (C:\Users\njste\code\experience-engine\platform\node_modules\bluebird\js\release\async.js:93:12)
at _drainQueue (C:\Users\njste\code\experience-engine\platform\node_modules\bluebird\js\release\async.js:86:9)
at Async._drainQueues (C:\Users\njste\code\experience-engine\platform\node_modules\bluebird\js\release\async.js:102:5)
at Immediate.Async.drainQueues [as _onImmediate] (C:\Users\njste\code\experience-engine\platform\node_modules\bluebird\js\release\async.js:15:14)
at processImmediate (internal/timers.js:439:21)
[2020-02-26T04:11:31.638Z] error Impossible to register the 'strapi_webhooks' model.
[2020-02-26T04:11:31.639Z] error TimeoutError: Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx) call?
at C:\Users\njste\code\experience-engine\platform\node_modules\knex\lib\client.js:348:17
at tryCatcher (C:\Users\njste\code\experience-engine\platform\node_modules\bluebird\js\release\util.js:16:23)
at C:\Users\njste\code\experience-engine\platform\node_modules\bluebird\js\release\catch_filter.js:17:41
at tryCatcher (C:\Users\njste\code\experience-engine\platform\node_modules\bluebird\js\release\util.js:16:23)
at Promise._settlePromiseFromHandler (C:\Users\njste\code\experience-engine\platform\node_modules\bluebird\js\release\promise.js:547:31)
at Promise._settlePromise (C:\Users\njste\code\experience-engine\platform\node_modules\bluebird\js\release\promise.js:604:18)
at Promise._settlePromise0 (C:\Users\njste\code\experience-engine\platform\node_modules\bluebird\js\release\promise.js:649:10)
at Promise._settlePromises (C:\Users\njste\code\experience-engine\platform\node_modules\bluebird\js\release\promise.js:725:18)
at _drainQueueStep (C:\Users\njste\code\experience-engine\platform\node_modules\bluebird\js\release\async.js:93:12)
at _drainQueue (C:\Users\njste\code\experience-engine\platform\node_modules\bluebird\js\release\async.js:86:9)
at Async._drainQueues (C:\Users\njste\code\experience-engine\platform\node_modules\bluebird\js\release\async.js:102:5)
at Immediate.Async.drainQueues [as _onImmediate] (C:\Users\njste\code\experience-engine\platform\node_modules\bluebird\js\release\async.js:15:14)
at processImmediate (internal/timers.js:439:21)`
```
**Code snippets**
My database.json:
```
{
"defaultConnection": "default",
"connections": {
"default": {
"connector": "bookshelf",
"settings": {
"client": "mysql",
"database": "platform",
"host": "localhost",
"port": 3306,
"username": "root",
"password": ""
},
"options": {}
},
"whisper": {
"connector": "mongoose",
"settings": {
"client": "mongo",
"host": "localhost",
"port": 27017,
"database": "platform",
"username": "",
"password": ""
},
"options": {}
}
}
}
```
My Dependencies:
```
"axios": "^0.19.0",
"config": "^3.2.4",
"core-js": "^2.5.7",
"hashids": "^2.1.0",
"jest": "^24.9.0",
"knex": "latest",
"lodash": "^4.17.15",
"magento-api-rest": "^1.1.0",
"mysql": "latest",
"node-cache": "^5.1.0",
"paypal-rest-sdk": "^1.8.1",
"strapi": "3.0.0-beta.18.7",
"strapi-admin": "3.0.0-beta.18.7",
"strapi-connector-bookshelf": "3.0.0-beta.18.7",
"strapi-connector-mongoose": "^3.0.0-beta.18.7",
"strapi-plugin-content-manager": "3.0.0-beta.18.7",
"strapi-plugin-content-type-builder": "3.0.0-beta.18.7",
"strapi-plugin-documentation": "3.0.0-beta.18.7",
"strapi-plugin-email": "3.0.0-beta.18.7",
"strapi-plugin-graphql": "3.0.0-beta.18.7",
"strapi-plugin-upload": "3.0.0-beta.18.7",
"strapi-plugin-users-permissions": "3.0.0-beta.18.7",
"strapi-provider-upload-google-cloud-storage": "^3.0.0-beta.18",
"strapi-utils": "3.0.0-beta.18.7",
"stripe": "^7.14.0",
"taxjar": "^3.1.0",
"validator": "^12.1.0",
"woocommerce-api": "^1.5.0"
```
**Additional Context***
I have both a MySQL and MongoDB data connection.
Also from knex itself:
opened 09:43AM - 26 Sep 18 UTC
closed 05:56PM - 26 Sep 18 UTC
insightful
# Environment
Knex version: 0.15.2
Database: sqlite3
OS: Ubuntu 18
I'm g… etting lots of errors like `TimeoutError: Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx) call?`
Any ideas? All my code lives in this one file: https://github.com/umaar/wiki-globe/blob/master/index.js - that code powers [this globe](https://umaar.com/globe/) which I posted in a [Hacker News comment](https://news.ycombinator.com/item?id=18069968) and in turn led to the discovery of such error.
An example query looks like this:
```js
await knex('edits').insert([{
field1: JSON.stringify(data),
field2: 'field2'
}]);
```
Does sqlite3 only allow a single connection to it because it's file-based? I'll try adding `.transacting()` calls to see if that makes a difference.
I guess it comes down to: some technical limitation with sqlite3 (maybe lack of pooling?) or some badly written code DB/queries on my part! Any insight you have would be much appreciated, thanks!
opened 01:41PM - 27 Apr 20 UTC
closed 09:25PM - 10 Aug 21 UTC
# 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
1. Initially, all knex connections/queries failed (timed out). I was able to fix regular connections by upgrading `knex` to `0.21.0` and `node-pg` to version 8.x. However, running migrations using `knex migrate:latest` or `npx knex migrate:latest` is still failing.
2. 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
```
And Stack overflow:
Short answer is you may need to tweak your pool settings which can be found here: https://strapi.io/documentation/developer-docs/latest/concepts/configurations.html#database
If you have a moderately sized project, generally yes, because the hobby DB type has very very small resource limits (below what even PG themselves recommend)
mingxi
February 3, 2021, 3:21pm
4
@DMehaffy Thank you for the fast answer!
By the way, I have the database Heroku Postgres (Hobby Basic ).
Should I rather upgrade my Strap dyno Type or my database, or both?
Many thanks!
mingxi
February 3, 2021, 3:49pm
5
@DMehaffy I just upgraded my Dyno Type to “Standard 1x”, but nothing happened, the problem is still there. Now it looks like I have to upgrade my Postgres database to “Standard 0”.
mingxi
February 3, 2021, 5:48pm
6
@DMehaffy My strapi is now set to Dyno Standard 1x and Postgres Database Standard-0 . Unfortunately, the problem has not yet been resolved and must be something else.
Do you have another idea?
@mingxi as I linked above, you will probably need to tune your Knex pool (tarn) settings. All of those various issues I linked should have some additional context.
I can’t give you a copy paste answer for the tuning as it varies project to project.
w3cj
February 22, 2021, 5:51pm
8
For anyone else that comes across this error while attempting to deploy to heroku, here is how I fixed it.
I added the line ssl: { rejectUnauthorized: false }
to the database connection settings.
It looks like the official strapi documentation now includes this, but I was attempting to deploy a legacy application that did not have this config. https://strapi.io/documentation/developer-docs/latest/concepts/configurations.html#example
return {
connections: {
default: {
settings: {
client: 'postgres',
host: env('DATABASE_HOST', '127.0.0.1'),
port: env.int('DATABASE_PORT', 5432),
database: env('DATABASE_NAME', 'strapi'),
username: env('DATABASE_USERNAME', 'strapi'),
password: env('DATABASE_PASSWORD', 'strapi'),
schema: 'public',
ssl: { rejectUnauthorized: false }, // this line is required
},
}
}
}
Along with connection and pool, add acquireConnectionTimeout, and give this a big value. This worked for me. I had to take Strapi support inputs to resolve this! In my case, I noted that the error would occur after 60 seconds. I tried multiple connection pool configurations and the issue repeated until adding acquireConnectionTimeout.
I ended up creating self hosting solution after encountering this issue from heroku and render… if anyone interested you can follow details at Strapi (Headless CMS), Google Cloud Run, and PostgreSQL | by Ganesh, Mohan | Jan, 2023 | Medium