Error while trying to start mflix-js app using npm start

Is anyone encountring this same error when trying to start the mflix app using npm start:

Looks like you’re unable to connect to your Atlas instance of mongoDB. Are you behind a corporate or school firewall of some kind? Many of them block the connection, you can try piniging to see if you’re being blocked.

You may have to run a local instance of mongodb and import the data if that is the case.
Or you can use a VPN.

Actually, I am not using any kind of corporate or school firewall or proxy. Yet, I will try to run a local instance of the database and connect the mflix app to it. Thus being said, and giving the fact that I am still new to mongodb (this is my second course after m001), could you please provide me with any hint or tutorial on how to setup and run the mflix databse locally using mongod. Thanks

Hi Ramzi_40786,

Please make sure you have whitelisted IP for your system from Atlas account.
Login to Atlas, click on Security Tab -> IP Whitelist -> Add IP Address

If you are using Atlas only for this course, you can check “Allow Access from anywhere”.

Let me know if that helps.


Hello Sir,
Indeed, I already did that and followed every step in the readme.rst file yet still have the same problem. In fact, I was able toconnect to the database using the mongoshell and the standard connection string. However, I was not able to connect from the mongoshell using the short connection string also (P.S: My mongoshell version is v4.0.4). I guess the problem is related to the short version of the Atlas connection string.
Here is the error when I run npm test -t db-connection

Could you share your connection string you are using in your .env file?

Of Course,
Here it is,

1 Like


Thanks for that! Please try the following for me:

  1. In a terminal or shell, type node -v. Provide this output in your reply.
  2. Again in your shell, type npm -v and provide this output in your reply.
  3. Within your mflix-js directory, delete the node_modules directory.
  4. Run npm install again from within the mflix-js directory.
  5. If there is a file called npm-debug.log, please PM me the contents of that file.

The error you are seeing is stemming from Jest not being able to initialize a MongoClient in its internals to use to run the tests. When it tries to call close() on it, it isn’t there so errors as it is undefined.

Hi @Ramzi_40786. I’ve had the same issue and I agree that this has something to do with the driver bundled with the code. However, I was able to fix it by selecting the standard connection string instead of the short SRV. So my MFLIX_DB_URI looks like this:


Hope this helps!