Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

390
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda