Unable to Connect with mongo Cluster

I whitelisted all the IP’s, but unable to connect and getting the error.

It looks like this is a MongoDB Atlas cluster. Please ensure that your IP whitelist allows connections from your network.

0.0.0.0/0 (includes your current IP address)

Hi @Muhammad_Abdul_Rehman_22238,

Is the firewall disabled on your system? Seems like network might be blocking the connection to the cluster.

Kanika

I am unable to access my cluster from anywhere. unable to resolve on ping anywhere. I think this might be the issue.

my cluster address is mflix-wj8we.mongodb.net

I am able to ping the uri, but authentication error when trying to connect, so you may want to cross-check that too. :slight_smile:

Kanika

OK. I tried it on Lan, Wifi and even using mobile connection on my site. It is not resolving anywhere. Can you share the IP. I will try it.

IP addresses:

mflix-shard-00-00-wj8we.mongodb.net 3.216.204.162
mflix-shard-00-01-wj8we.mongodb.net 18.211.56.222
mflix-shard-00-02-wj8we.mongodb.net 3.212.105.151

Kanika

MFLIX_DB_URI=mongodb+srv://m220student:@mflix-4b3ha.mongodb.nMFLIX_DB_URIet/test?retryWrites=true&w=majority
MFLIX_NS=mflix
PORT=5000

above is my env file (xyz.env) i renamed ,for this i am getting this below error

  at MongoEnvironment.teardown (test/config/mongoEnvironment.js:22:35)

Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 0.504s
Ran all test suites matching /mongoclient/i.
Teardown Mongo Connection
npm ERR! Test failed. See above for more details.

D:\study\mflix-js>npm test -t mongoclient

server@1.0.0 test D:\study\mflix-js
jest --passWithNoTests “mongoclient”

Determining test suites to run…Setup Mongo Connection
FAIL test/lessons/mongoclient.spec.js
● Test suite failed to run

TypeError: Cannot read property 'close' of undefined   

  20 | 
  21 |   async teardown() {
> 22 |     await this.global.mflixClient.close()       
     |                                   ^
  23 |     await super.teardown()
  24 |   }
  25 | 

  at MongoEnvironment.teardown (test/config/mongoEnvironment.js:22:35)

Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 1.415s

The error

indicates that your code does not create the mflixClient member of the correct type.

Check the connection string, I believe there is need for correction here.

Kanika

thanks i fixed with string correction

1 Like