0

I have created a cluster and would like to access it with MongoDB Compass.

Via Connect -> I have MongoDB Compass I get the following connection string:

mongodb+srv://myname:<password>@myname.nauqp.mongodb.net/dws

When I enter this string in MongoDB Compass and insert my password and replace test with the name of my DB, the connect button is disabled and the following error message below it:

querySrv ENOTFOUND _mongodb._tcp.myname.nauqp.mongodb.net

I also have the same problem when I want to establish the connection via mongoose. There I get the error message:

Error: querySrv ENOTFOUND _mongodb._tcp.myname.nauqp.mongodb.net
[nodemon] app crashed - waiting for file changes before starting ...

My config looks like this:

const connectDB = async () => {
    try {
        const connection = await mongoose.connect(process.env.MONGO_URI, {
            useUnifiedTopology: true,
            useNewUrlParser: true,
            useCreateIndex: true,
        })

    } catch (error) {
          // error handling
    }
}

The MONGO_URI in my .env file looks like this:

mongodb+srv://myname:<password>@myname.nauqp.mongodb.net/dws?retryWrites=true&w=majority

MongoDB Compass Version: 1.22.1 (1.22.1)

Node Version: v14.15.0

What am I doing wrong?

Codehan25
  • 2,704
  • 10
  • 47
  • 94

1 Answers1

0

It's the cluster's name after the @

mongodb+srv://myname:<password>@clustersname.nauqp.mongodb.net/dws?retryWrites=true&w=majority
  • In my case, the cluster is called exactly like the username. Is this a problem? I've just replaced it with "myname" here. But even if I change the name, the button in MongoDB compass is still disabled.. – Codehan25 Nov 03 '20 at 16:04