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

972
Vistas
MongoNetworkError: connection establishment was cancelled

I'm trying to update a database using Mongoose, but I'm getting this Network error while running my node app.

const mongoose = require('mongoose')
mongoose.connect("mongodb://localhost:27017/fruitsDB")
const fruitsSchema = new mongoose.Schema({
    name: {
        type: String,
        required: [true, "Why no Name?"]
    },
    rating: {
        type: Number,
        min: 1,
        max: 10
    },
    review: String
 });
 const Fruit = mongoose.model("Fruit", fruitsSchema)
Fruit.find(function(err, fruits){
    if(err){
        console.log(err)
    }
    
    
    else{
        mongoose.connection.close();
        
        fruits.forEach(function(fruit){
            console.log(fruit.name)
        })
    }
})
Fruit.updateOne({_id:"62b6a681eb136efde7ed17bc"}, {name: "Banana"}, function(err){
    if(err){
        console.log(err)
    }
    else{
        console.log("Successfully updated the document")
    }
})

Error: Commnad line error while running the node app

MongoNetworkError: connection establishment was cancelled
    at connectionFailureError 
    at CancellationToken.<anonymous> 
    at Object.onceWrapper (node:events:641:28)
    at CancellationToken.emit (node:events:527:28)
    at ConnectionPool.close 
    at Server.destroy 
    at destroyServer 
    at eachAsync

It's a simple Node app created using Mongoose.

about 4 years ago · Juan Pablo Isaza
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