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

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

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 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