How can I connect to the running MongoDB instance using MongoDB Compass

Issues information

  • OS: Mac
  • databases: MongoDB
  • Programming language and version: Node.js 16
  • Link to your project on Github/Gitlab: private

Hi all. I’m going through connecting a MongoDB to a simple node express rest API.
My question - How can I connect to the running MongoDB instance using MongoDB Compass?
The guide in the docs mention env vars to be used within the app script,
but I wasn’t able to use the URI to connect via compass.
Am I missing something?

Dockerfile content

FROM node:16-alpine
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
EXPOSE 3333
CMD [ "npm", "start" ]

Problem solved. once the deployment was successful, I was able to connect with Compass…

1 Like