MongoDB and Mongoose - Install and Set Up Mongoose

Glad to hear it.

Good luck.

1 Like

Has anybody tried this recently? I can’t connect to Mongoose. Getting the following error:
(node:14936) UnhandledPromiseRejectionWarning: MongoNetworkError: connection 3 to closed

It passes the first 2 tests which are that mongodb and mongoose are in the dependencies. Also, the instructions are outdated, as mlab is now mongodb Atlas and the current uri looks like this:


Could this be why it is not able to connect to Mongoose?

1 Like

FCC: mlab is no longer accepting new users. Does this mean these challenges can no longer be completed? Can you please look into this?

1 Like

@mscanza, I’ll do a test run later this evening, if no one hasn’t got to it by then…

im having the same issue as user @mscanza. That you have to use Mongo Atlas meaning i can’t follow the instructions in the challenge. Does anyone know when the (apis-and-microservices) challenges will be updated or a quick fix to be able to complete the challenge? Thank you.

1 Like

I have just confirmed that the lessons still work even after the changes made from the acquisition of mlab by mongodb, these instructions need to be fully changed however, I will look to submitting a PR or see if one hasn’t already been submitted.

But, it should not stop anyone from continuing with the lessons, since the instructions in MongoDB Atlas are pretty clear, see below for brief instructions or go to this link for a more detailed set of instructions from a PR of the lesson that is pending approval.

  1. Create your MongoDB Atlas account.
  2. As soon as you login, it will walk you through building your first cluster - may take a few minutes to complete.
  3. Then following the green tab in the bottom left of the screen, click on Create your first database user, follow the instructions and create a user with a password.
  4. In the same green Get started tab click on Whitelist your IP address, warning here, glitch will not connect if you don’t allow all IP addresses, which is what I did for it to work.
  5. Click Connect to Your Cluster > click connect in the sandbox window, and then click connect your application in the pop up window, then copy the connection string, and paste it in your .env file in glitch and substitute the password you provided in step 3 for the <password> area , and you are good to go. Test the first lesson and it should pass.

mongoDB Atlas says it requires MongoDB version 4.0 for the free tier clusters . If you are using Mongoose, this means that you would need mongoose > 5.2 to have a compatible mongoDB driver that Atlas can use

Submit the link to your LIVE page from glitch for the challenge to pass and not the link to your glitch editor


Thank you Dereje1 this was extremely helpful. Whitelisting all ip addresses fixed it.

Hi Team,

I cannot establish connection to database.
My code:
.env file

var mongodb = require(‘mongodb’);
const mongoose = require(‘mongoose’);
mongoose.connect(process.env.MONGO_URI,{useNewUrlParser: true});


“name”: “fcc-mongo-mongoose-challenges”,
“version”: “0.0.1”,
“description”: “A boilerplate project”,
“main”: “server.js”,
“scripts”: {
“start”: “node server.js”
“dependencies”: {
“express”: “^4.16.4”,
“body-parser”: “^1.18.3”,
“mongoose”: “^5.4.19”,
“mongodb”: “^3.1.17”
“engines”: {
“node”: “4.4.5”
“repository”: {
“type”: “git”,
“url”: "
“keywords”: [
“license”: “MIT”
Please help!!!

My console output

I forgot to mention. I’m on Ubuntu 16.04.

see here first: MongoDB and Mongoose - Install and Set Up Mongoose

1 Like

Thanks for the reference Dereje1. I’m a little bit confused here. I tried to change dependencies version and it did not work out. If you know the trick, please tell…

Did you whitelist all ip addresses in MongoDB atlas as pointed out in the link I gave you ?
If you followed the instructions I posted above and still can’t get it to work post your glitch link and i’ll look into it

Hey Dereje1,
I think all steps suggested in your links were taken. IP addresses where white listed.


Here is a link to my Glitch.
Great thanks in advance

If you click on allow all ip addresses you should see (includes your current IP address) included in your ip address list, which means you may not have done it correctly. Your glitch app connects fine for me with my own connection string…


Thank you Good Sir. It’s working fine now.

good, I have merged your thread to the main one

Hi, I’ve encountered an issue with this exercise. I believe my code is correct, however when I submitted my solution, all the tests failed, and I saw this error message on the Chrome console:

“Access to XMLHttpRequest at ‘/package.json’ from origin ‘’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.”

Does anyone know how I can fix this?

thanks for the tip on allowing all ip addresses on glitch, i was running around in circles trying to figure out why it wasnt working!