"Cannot destructure property 'client' of 'db.config.connection' as it is undefined" when deployed in cPanel shared hosting

System Information
  • Strapi Version: 4.15.0
  • Operating System: Linux 4.18.0-425.19.2.lve.el7h.x86_64
  • Database: MariaDB
  • Node Version: 18.16.1
  • NPM Version: 9.5.1
  • Yarn Version: -

After I manually deployed Strapi application in cPanel Shared Hosting with proper environment variables setup and PM2 setup, the application won’t show as it showed 503 error.

I checked PM2 logs, I got this error continuously:

0|app  | [2023-10-31 03:12:18.372] debug: ⛔️ Server wasn't able to start properly.
0|app  | [2023-10-31 03:12:18.375] error: Cannot destructure property 'client' of 'db.config.connection' as it is undefined.
0|app  | TypeError: Cannot destructure property 'client' of 'db.config.connection' as it is undefined.
0|app  |     at getDialect (/home/u1572792/nodevenv/public_html/cms.mysite.com/18/lib/node_modules/@strapi/database/dist/index.js:1014:11)
0|app  |     at new Database (/home/u1572792/nodevenv/public_html/cms.mysite.com/18/lib/node_modules/@strapi/database/dist/index.js:6114:20)
0|app  |     at Database.init (/home/u1572792/nodevenv/public_html/cms.mysite.com/18/lib/node_modules/@strapi/database/dist/index.js:6100:16)
0|app  |     at Strapi.bootstrap (/home/u1572792/nodevenv/public_html/cms.mysite.com/18/lib/node_modules/@strapi/strapi/dist/Strapi.js:365:39)
0|app  |     at Strapi.load (/home/u1572792/nodevenv/public_html/cms.mysite.com/18/lib/node_modules/@strapi/strapi/dist/Strapi.js:419:16)
0|app  |     at async Strapi.start (/home/u1572792/nodevenv/public_html/cms.mysite.com/18/lib/node_modules/@strapi/strapi/dist/Strapi.js:213:9)

It’s only happened when I deployed to shared hosting, the Strapi app doesn’t show any problem when in local development. Is there way to fix them in cPanel shared hosting? I through it has problem with reading env parameter, but I checked the env params with process.env via node command and it showed correctly.

Anyway, I build them locally in my computer before I deploy them to shared hosting as I unable to build them in shared hosting due to limited resources (process terminated).

Got same error and got so pissed that this bulls*it like this happens so often in Strapi… But it is on localhost

Getting the same error…
Did you find a soltution (or the cause)?

Node version: 18
Strapi version: 4.20.3

I just solved this problem.
I use docker compose outside of project and build.
The Dockerfile in project COPY path have to change.
Because my build context in docker compose is “.”
so Dockerfile code “COPY . .”,now need to use “COPY ./backend .” *backend is my,otherwise your code is not in correct folder.

Can you explain in more detail, please? Because I’m getting this issue in local continuously

Hello @Dread @vitakili @rafimaryudwika @weicheng-one,

I was able to solve this issue. It turns out that a configuration in TypeScript caused the problem. All we need to do is remove “noEmit”: true from tsconfig.json.