Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connect to mongodb / documentDB #14535

Open
1 task done
rakshitweb opened this issue Apr 25, 2024 · 5 comments
Open
1 task done

Connect to mongodb / documentDB #14535

rakshitweb opened this issue Apr 25, 2024 · 5 comments
Labels
needs clarification This issue doesn't have enough information to be actionable. Close after 14 days of inactivity

Comments

@rakshitweb
Copy link

Prerequisites

  • I have written a descriptive issue title

Mongoose version

^8.0.2

Node.js version

20.9.0

MongoDB version

5.0.0

Operating system

Windows

Operating system version (i.e. 20.04, 11.3, 10)

10

Issue

I am not able to connect to document DB using mongoose.
I am able to connect to the same using mongo shell, and compass.

Getting this error: Failed to connect with Mongo DB MongooseServerSelectionError: connect ETIMEDOUT

@rakshitweb rakshitweb added help This issue can likely be resolved in GitHub issues. No bug fixes, features, or docs necessary help wanted labels Apr 25, 2024
@humblewolfstudio
Copy link

Can you post the code you're trying to run to connect to the document DB?

@rakshitweb
Copy link
Author

`
const mongoose = require('mongoose');
const dotenv = require('dotenv');
dotenv.config();

const DBConnect = () =>
mongoose.connect(process.env.DB_URL, {
tls: true,
tlsCAFile: 'global-bundle.pem',
directConnection: true
});

module.exports = DBConnect;
`

DB_URL: mongodb://:@<CLUSTER_NAME>:<CLUSTER_PORT>/<DB_NAME>

@vkarpov15
Copy link
Collaborator

And how are you importing and running DBConnect() ?

@vkarpov15 vkarpov15 added needs clarification This issue doesn't have enough information to be actionable. Close after 14 days of inactivity and removed help This issue can likely be resolved in GitHub issues. No bug fixes, features, or docs necessary help wanted labels May 1, 2024
@FaizBShah
Copy link
Contributor

@rakshitweb Is this a protected DB? Because in that case you will also need to add password to the url connection string, otherwise you won't be to connect to it

@humblewolfstudio
Copy link

@rakshitweb https://www.mongodb.com/docs/manual/reference/connection-string/ here you have some more information about mongodb connection strings if you need it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs clarification This issue doesn't have enough information to be actionable. Close after 14 days of inactivity
Projects
None yet
Development

No branches or pull requests

4 participants