Skip to content

How to connect to mongo atlas? #388

Description

@Taxi4you

I am trying to connect to mongo atlas cluster but I got the following error:

Error [MongoError]: failed to connect to server [<cluster-url>:27017] on first connect [Error: getaddrinfo ENOTFOUND <cluster-url>
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:67:26) {
  name: 'MongoError'
}]

This is how I am trying to connect:

const dbuser = <user>;
const dbpass = <pass>;
const dbClusterUrl = <cluster-uri>;
const dbName = 'test';
const dbOptions = `retryWrites=true&w=majority`
const dbUri = `mongodb+srv://${dbuser}:${dbpass}@${dbClusterUrl}/${dbName}?${dbOptions}`;

const db = require('mongojs')(dbUri, []);

How can it be achieved?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions