Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

233
Views
Creating an instance in Mongoose

I am getting this error: Mongoose Error: Operation users.insertOne() buffering timed out after 10000ms when trying to create an instance of User model. Here is the model/User.js

import mongoose from 'mongoose'

const UserSchema = new mongoose.Schema(
  {
    username: {
      type: String,
      min: 3,
      max: 20,
      unique: true,
    },
);

export default mongoose.model("User", UserSchema)

And routes/auth.js (where I send request to create User):

import express from 'express'
import User from "../models/User.js";
const router = express.Router();
//REGISTER
router.post("/register", async (req, res) => {
  try {
    //create new user
    const newUser = new User({
      username: req.body.username,
    });
    //save user and respond
    const user = await newUser.save();
    res.status(200).json("user saved");
  } catch (err) {
    res.status(500).json("error occured")
  }
});
export default router

I double checked and found no error at connecting MongoDB or handling get requests. Only problem is with creating User instance on mongoDB.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!