querySrv ECONNREFUSED _mongodb._tcp.cluster0.6hfdm.mongodb.net

const CONNECTION_URL = 'mongodb+srv://user:passsword@cluster0.mongodb.net/myFirstDatabase?retryWrites=true&w=majority';

const PORT = process.env.PORT || 5000;

mongoose.connect(CONNECTION_URL, {useNewUrlParser: true, useUnifiedTopology: true})

    .then(()=> app.listen(PORT, ()=> console.log(`server runniung on: ${[PORT]}`)))

    .catch((error)=> console.log(error.message));

mongoose.set('useFindAndModify', false);

Hi @Martin_Ntalika,

Welcome to the Community!

querySrv ECONNREFUSED _mongodb._tcp.cluster0.6hfdm.mongodb.net

You may wish to check out the steps listed in this post as a workaround. As noted in the post, the querySRV ECONNREFUSED error you’ve noted in the title of this post possibly indicates a SRV lookup failure. All official MongoDB drivers that are compatible with MongoDB server v3.6+ should support the SRV connection URI meaning that the issue may be related to environment’s network / DNS configuration.

By following the instructions in the post, you can try with the alternate string and see if you’re able to connect or get a different error.

Hope this helps.

Kind Regards,
Jason

2 Likes

My gratitude to you Jason saved the day

2 Likes

Thanks for the kind words Martin :slight_smile:

1 Like