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

602
Vistas
MongoDB failed to connect connection timed out: Connects via Atlas

When starting my app, I get the following error:

error: MongoNetworkError: failed to connect to server [localhost:27017] on first connect [MongoNetworkTimeoutError: connection timed out
    backend_1     |       at connectionFailureError (/usr/src/app/node_modules/mongodb/lib/core/connection/connect.js:342:14)
    backend_1     |       at Socket.<anonymous> (/usr/src/app/node_modules/mongodb/lib/core/connection/connect.js:310:16)
    backend_1     |       at Object.onceWrapper (events.js:421:28)
    backend_1     |       at Socket.emit (events.js:315:20)
    backend_1     |       at Socket._onTimeout (net.js:483:8)
    backend_1     |       at listOnTimeout (internal/timers.js:554:17)
    backend_1     |       at processTimers (internal/timers.js:497:7)]
    backend_1     |       at Pool.<anonymous> (/usr/src/app/node_modules/mongodb/lib/core/topologies/server.js:438:11)
    backend_1     |       at Pool.emit (events.js:315:20)
    backend_1     |       at /usr/src/app/node_modules/mongodb/lib/core/connection/pool.js:562:14
    backend_1     |       at /usr/src/app/node_modules/mongodb/lib/core/connection/pool.js:995:11
    backend_1     |       at /usr/src/app/node_modules/mongodb/lib/core/connection/connect.js:32:7
    backend_1     |       at callback (/usr/src/app/node_modules/mongodb/lib/core/connection/connect.js:280:5)
    backend_1     |       at Socket.<anonymous> (/usr/src/app/node_modules/mongodb/lib/core/connection/connect.js:310:7)
    backend_1     |       at Object.onceWrapper (events.js:421:28)
    backend_1     |       at Socket.emit (events.js:315:20)
    backend_1     |       at Socket._onTimeout (net.js:483:8)
    backend_1     |       at listOnTimeout (internal/timers.js:554:17)
    backend_1     |       at processTimers (internal/timers.js:497:7),


However, I can connect to the MongoDB service via MongoDBCompass and the Database connection tool in WebStorm, using the same connection string. "mongodb://localhost:27017/fmis"

I'm struggling to find the root cause to even try and solve it myself.

Update: as asked in the comments, I am running docker

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

I solved this by including the following in my connection configuration:

mongoose.connect(
    db,
    {
        ...
        useUnifiedTopology: true   //THIS SETTING
    })
    ...
)
over 4 years ago · Santiago Trujillo 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