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

387
Views
Why my mongodb and node js connection is unsuccessful?

Hey Everyone. This is my Frist question on stack overflow .

I am tried to Connect my application with Mongodb. Even if I connect successfully to the server , the Mongodb connection is unsuccessful. I also set the Mongodb connection URL correctly.

Here I changed the mongoose version and Ip addresses . But it didn't work.

const express = require("express");
const mongoose = require("mongoose");
const bodyParser = require("body-parser");
const cors = require("cors");
const app =express();
require("dotenv").config();

const PORT = process.env.PORT || 8070;

app.use(cors());
app.use(bodyParser.json());

const URL = process.env.MONGODB_URL;

mongoose.connect(URL,{
    useCreateIndex:true,
    useNewUrlParser:true,
    useUnifiedTopology:true,
    useFindAndModify:false,
});

const connection = mongoose.connection;
connection.once("open",() =>{
    console.log("mongodb connection succes!");
})

app.listen(PORT,() =>{
    console.log(`server is running on port ${PORT}`);
})

Here is given error

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

In the error, it is mentioned that you have not whitelisted your IP address to Atlas cluster. You need to do that. You can see here how to add your current IP address on your Atlas cluster's IP whitelist.

If this also don't work, then try changing your internet connection. Many times router block connection to 27017 port. So shifting to your mobile hotspot or other connection would work.

over 4 years ago · Santiago Trujillo Report

0

You need to whitelist your public IP address or else make the connection open to the world 0.0.0.0/0.

enter image description here

over 4 years ago · Santiago Trujillo Report

0

I have faced the same problem some days earlier. I don't know why it happened but I can give you a hack. You need to whitelist your IP address and also allow for anywhere both to your atlas cluster. This may fix the error as it fixed mine.

over 4 years ago · Santiago Trujillo 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!