Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

384
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda