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

401
Visualizações
Can't insert data with mongoDB atlas; Error: queryTxt ETIMEOUT

I've tried to connect to mongodb with node.js, but get the following error. Although I've tried several available solution in this platform, like, changing my DNS to Google's Public DNS, downgrading the node.js driver's version for connection string, but they did not work out for me.

Error: queryTxt ETIMEOUT cluster0.1moqz.mongodb.net
at QueryReqWrap.onresolve [as oncomplete] (dns.js:213:19) {
  errno: 'ETIMEOUT',
  code: 'ETIMEOUT',
  syscall: 'queryTxt',
  hostname: 'cluster0.1moqz.mongodb.net'
}

here is my server side code:

const { MongoClient, ServerApiVersion } = require('mongodb');
const uri = `mongodb+srv://${process.env.DB_USER}:${process.env.DB_PASS}@cluster0.1moqz.mongodb.net/myFirstDatabase?retryWrites=true&w=majority`;
const client = new MongoClient(uri, { useNewUrlParser: true, useUnifiedTopology: true, serverApi: ServerApiVersion.v1 });

async function run() {
    try {
        await client.connect();
        const userCollection = client.db('myTestDB').collection('users');
        const newUser = { name: "username", email: "abc@def.com" };
        const result = await userCollection.insertOne(newUser);
        console.log("adding new user", result); 
    } 
    finally {
        await client.close();
    }

}
run().catch(console.dir);

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Have you added you IP address to the IP Access List?

You must add your IP to the access list in order to access the database (from that IP). To do this:

  1. Go to your MongoDB Atlas page
  2. In the sidebar, under "Security" select "Network access"
  3. Select the "IP Access List" tab
  4. Click the "ADD IP ADDRESS" button
  5. Enter your IP address (there should be a button that does this for you) and click "Confirm"
  6. You should be able to access your MongoDB database after a minute or so
about 4 years ago · Juan Pablo Isaza 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