Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mongoose can't connect: Error: querySrv ENOTIMP mongodb.tcp.cluster1-owfxv.mongodb.net

Mongoose can't connect to mogodb Atlas. It every times give me this error:

 Error: querySrv ENOTIMP _mongodb._tcp.cluster1-owfxv.mongodb.net

I am running inside kubernetes cluster inside minikube locally. If I run project directly then it works perfectly but with minikube it alwasy give me error.

Following is my code:

  const url = "mongodb+srv://name:[email protected]/test?retryWrites=true";

    const mongoDbOptions = {
        useNewUrlParser: true,
        reconnectTries: 10,
        autoReconnect: true

    };
    mongoose.connect(url, mongoDbOptions).then((r) => { }).catch((e) => {
        console.log(e);
    });

Error message is not so clear to me. Its strange that it works directly but with kubernetes cluster it does not work.

I will really appreciate for any contribution.

like image 224
Ayyaz Zafar Avatar asked Nov 26 '25 02:11

Ayyaz Zafar


1 Answers

Try using connection string compatible with mongo driver 2.2.12 or later i.e. one with mongodb://username:password@host1:port,host2:port,host3:port/databaseName

It's not clear why connection to mongodb is not working with new url.

like image 111
cEeNiKc Avatar answered Nov 27 '25 16:11

cEeNiKc



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!