Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

139
Views
App is not connecting to the mongodb Atlas

I start learning JavaScript on the freecodecamp and stuck on a challenge.

The challenge itself is to setup a mongoose. But every time I am submitting my answer it giving me an error of "mongoose should be connected to a database.

I checked the fcc forum on the same topic and all of the solutions not working for me

The challenge provide the starting code and all what is required is to setup mongo atlas and connect your app to it

In the app.js you should add

    require("dotenv").config();
    let mongoose = require("mongoose");

    mongoose.connect(process.env.MONGO_URI, {
      useUnifiedTopology: true,
      useNewUrlParser: true
    });

in the .env file MONGO_URI=mongodb+srv://userName:password@cluster0.rmycu.mongodb.net/myFirstDatabase

Where the userName and password are changed to mine without any prohibited symbols.

You should also add this dependencies to package.json

    "mongodb": "4.1.1",
    "mongoose": "6.0.5"

Any help appreciated

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Can you try to change connection config and use it without additional options:

mongoose.connect(process.env.MONGO_URI);

Since you are using Mongoose version higher than 6.0, these options are not available as config anymore, and are configured automatically.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!