Database Connections

I’ve getting intermittent errors on an Adonis app regarding “lost database connection”. I have never manually closed database connections before, my bad. And wondered if closing them manually would help and how/where would this be best achieved?

Any advice appreciated.

        "@adonisjs/ace": "^5.0.1",
        "@adonisjs/auth": "^3.0.5",
        "@adonisjs/bodyparser": "^2.0.2",
        "@adonisjs/cors": "^1.0.5",
        "@adonisjs/drive": "^1.0.2",
        "@adonisjs/fold": "^4.0.7",
        "@adonisjs/framework": "^5.0.5",
        "@adonisjs/ignitor": "^2.0.6",
        "@adonisjs/lucid": "^5.0.3",
        "@adonisjs/validator": "^5.0.3",
        "@adonisjs/vow": "^1.0.15",

Hi @jacksoncharles!

Adonis Lucid used Knex under the hood.
Knex is like industry standard and it has it’s own connection pool. It creates and releases connections as needed. You don’t have to worry about it manually. (You shouldn’t do it - might cause odd issues if you kill some connection by yourself).

lost database connection error is more like network layer problem.
Does it happen every time you connect to database right away or over some x time randomly?
What database are you using?

2 Likes

I think it comes from your database server. Check them.