Dockerized App cant connect to a local mongodb server without docker

I’m trying to connect to MongoDB in a dockerized app, and i dont know how to do this.

My Docker File

FROM node:18-bullseye

WORKDIR /Bot_granada_rp

COPY . .

RUN npm install

RUN npm install -g pm2

EXPOSE 27017


CMD ["pm2-runtime", "start", "index.js"]

It’s a discord bot. I have an anti-crash. The anti-crash sends this:

MongooseError: Operation criptos.find() buffering timed out after 10000ms at Timeout.(/Bot_granada_rp/node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js:185:23)
at listOnTimeout (node:internal/timers:569:17)
at process.processTimers (node:internal/timers:512:7)