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

883
Visualizações
const err = new MongooseError(message);

I am trying to create a project which allows the user to enter "email", "username" and "Password" to register to the site, When I try to enter a user using the "username", email" and "password" to enter this site, I get the following error:

Backend server is running
not connected
C:\Users\odewo\chat-app\NODE-REST-API\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:149
          const err = new MongooseError(message);
                      ^

MongooseError: Operation `users.insertOne()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\odewo\chat-app\NODE-REST-API\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:149:23)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7)

Below is my mongoose code:

mongoose.connect(process.env.MONGO_URL, {
  userNewUrlPaser: true,
  useUnifiedTopology: true,
  useCreateIndex: true,
})
  .then(() => {
    console.log('Connected to MongoDB');
  })
  .catch((e) => {
    console.log('not connected');
  });

This is auth.js code for routes:

const router = require('express').Router();
const User = require('../models/User');

//  REGISTER
router.get('/register', async (req, res) => {
  const user = await new User({
    username: 'samson',
    email: 'samson@gmail.com',
    password: '123456',
  });

  await user.save();
  res.send('ok');
});
module.exports = router;

I will really appreciate your help

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

0

Check your MONGO_URL and make sure your password or username is not wrapped in < > tags. I think your code is fine but its obvious that there are some problems. I would be checking the .env file to make sure.

about 4 years ago · Juan Pablo Isaza Relatório

0

The problem is not solved by removing the await. It is better to implement this function asynchronously. You must log in to your mongo account and add your IP address from the Network Access part.

enter image description here

about 4 years ago · Juan Pablo Isaza Relatório

0

you should remove the await before the new User declaration , use await just when you are waiting for the result of a promise like in await user.save()

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