Quantcast
Channel: Active questions tagged mongodb-atlas - Stack Overflow
Viewing all articles
Browse latest Browse all 271

MongoDB atlas connection fails with error MongoServerSelectionError: connection to 52.64.0.234:27017 closed

$
0
0

I have set up a mongodb Atlas free tier cluster. When I try to connect to it with node js, it throws an error. I have white listed my IP both manually and with select current. I have also tried adding +srv to my connection url but that just causes more errors.

Here is the node js code I was trying to connect with

const { MongoClient } = require("mongodb");                                                                                                                                       const url = "mongodb://user1:password1!@cluster0-shard-00-00-bc7dh.mongodb.net/test?retryWrites=true&w=majority&useNewUrlParser=true&useUnifiedTopology=true";const client = new MongoClient(url);async function run() {    try {        await client.connect();        console.log("Connected correctly to server");    } catch (err) {        console.log(err.stack);    }    finally {        await client.close();    }}run().catch(console.dir);

and here is the error I get

MongoServerSelectionError: connection to 52.64.0.234:27017 closed at Timeout._onTimeout (C:\Users\YOUNG\node_modules\mongodb\lib\core\sdam\topology.js:430:30) at listOnTimeout (internal/timers.js:549:17) at processTimers (internal/timers.js:492:7)

people with a similar problem were able to solve it by whitelisting their ip addresses, but it hasn't worked for me. What could possibly be the problem?

I have tried allowing access for all ips but the error persists and when I use the uri with +srv, I get the following error

MongoServerSelectionError: Authentication failed.at Timeout._onTimeout (C:\Users\YOUNG\node_modules\mongodb\lib\core\sdam\topology.js:430:30)at listOnTimeout (internal/timers.js:549:17)at processTimers (internal/timers.js:492:7)

Viewing all articles
Browse latest Browse all 271

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>