question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MongoDB connection fails with current default options

See original GitHub issue

Since ssl option is set to false, it is not possible to establish a connection to a MongoDB server using an ecrypted connection (e.g. MongoDB Atlas). This option is not even featured in how to connect to each database in README.md. It would be great if the documentation on how to get started is updated as well as defaulting ssl option to true.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:14 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
freitzzzcommented, Sep 15, 2020

@freitzzz according to the mongodb docs you can - https://docs.mongodb.com/manual/reference/connection-string/#connection-options

Didn’t know about this, thank you

1reaction
kojukacommented, Apr 21, 2022

@freitzzz

Yes. And using that repo I was able to get mine working! Thanks!

for others who struggle with this. My changes were this:

  1. Add ?retryWrites=true&w=majority to the end of the mongo url
  2. Add the following options
const eventStoreClient = eventstore({
  type: 'mongodb',
  url: config.MONGO_URL,
  eventsCollectionName: 'events', // optional
  snapshotsCollectionName: 'snapshots', // optional
  transactionsCollectionName: 'transactions', // optional
  timeout: 10000, // optional
  options: {
    ssl: true,
    autoReconnect: false,
    useNewUrlParser: true
  }
});

This is what I added.

 options: {
    ssl: true,
    autoReconnect: false,
    useNewUrlParser: true
  }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshoot Connection Issues — MongoDB Atlas
This error may occur when using the default DNS server that your ISP provides. That DNS server might not support SRV lookups that...
Read more >
Can't connect to mongod with the newly created user - M103
I connected to mongo and created a new user, but i can't access with the --auth command and -u -p from my user:...
Read more >
Compass Connection Errors - MongoDB
This error often occurs when: You provide no hostname or an invalid hostname to the Compass connect dialog. The destination server rejects a...
Read more >
Error: couldn't connect to server 127.0.0.1:27017 - MongoDB
I'm following the install guide “Install MongoDB Community Edition on macOS”. I'm getting the following error: MongoDB shell version v4.2.3
Read more >
Can't connect to mongodb.Could not connect to any servers in ...
while trying to connect with mongodb i'm getting this error ... Make sure your current IP address is on your Atlas cluster's IP...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found