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

313
Visualizações
Connecting code to MongoDB database gives error: Error: querySrv ENODATA _mongodb._tcp.cluster0.h5prp.mongodb.net

I'm coding a discord bot and I want to connect it to a mongoDB database. However when doing this, I get this error,

Error: querySrv ENODATA _mongodb._tcp.cluster0.h5prp.mongodb.net
    at QueryReqWrap.onresolve [as oncomplete] (node:dns:228:19) {
  errno: undefined,
  code: 'ENODATA',
  syscall: 'querySrv',
  hostname: '_mongodb._tcp.cluster0.h5prp.mongodb.net'
}

Here is my code:

client.on('ready', () => {
    console.log('The bot is ready!')
  const dbOptions = {
    // These are the default values
    keepAlive: true
  }
  new WOKCommands(client, {
    // The name of the local folder for your command files
    commandsDir: path.join(__dirname, 'commands'),
    // Allow importing of .ts files if you are using ts-node
    typeScript: true,
    // Pass in the new dbOptions
    dbOptions,
    // Pass in your own mongo connection URI
    mongoUri: 'mongodb+srv://discordbot:******@cluster0.h5prp.mongodb.net/myFirstDatabase?retryWrites=true&w=majority'
  })
})

I looked through documentation and other posts but could not find anything that solves my problem. I'm using Node.js v17.1.0. I'm using WOKCommands and following this tutorial series https://youtube.com/playlist?list=PLaxxQQak6D_f4Z5DtQo0b1McgjLVHmE8Q

I've allowed all IP Addresses to access my database, I've ensured my IP address is whitelisted

Any help appreciated.

Thanks

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

0

I needed to change the mongoDB connection URI to an earlier Node.js version.

I changed it to version '2.2.12 or later' and it worked. mongoDB connection

Which game me a link like this: mongodb://discordbot:<password>@cluster0-shard-00-00.h5prp.mongodb.net:27017,cluster0-shard-00-01.h5prp.mongodb.net:27017,cluster0-shard-00-02.h5prp.mongodb.net:27017/myFirstDatabase?ssl=true&replicaSet=atlas-g86xz1-shard-0&authSource=admin&retryWrites=true&w=majority

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