Skip to content
Latchkey

mongodb-memory-server "Instance failed to start" / timeout in CI

The binary was present but the mongod process did not reach a ready state in time. The usual causes are a missing system library the binary links against, or a startup timeout too short for a slow runner.

What this error means

Test setup fails with "Instance failed to start" or a startup timeout from mongodb-memory-server, sometimes with a dynamic-linker error like libcrypto in the details.

node
StdoutInstanceError: Instance failed to start because a library is missing
or cannot be opened: "libcrypto.so.1.1"
    at MongoInstance.checkErrorInLine

Common causes

A missing shared library on a slim image

The mongod binary links against libraries such as libcrypto or libcurl that a minimal runner image does not provide, so it exits at launch.

A startup timeout too short for the runner

On a busy or small runner, mongod takes longer to become ready than the default start timeout allows.

How to fix it

Install the libraries the binary needs

Provide the shared libraries mongod links against, or pin a mongod version that matches the runner OS.

Terminal
sudo apt-get update
sudo apt-get install -y libcurl4 openssl ca-certificates

Raise the start timeout and pin the version

Give mongod more time to start and pin a version known to run on the runner image.

test-setup.js
import { MongoMemoryServer } from 'mongodb-memory-server';
const mongod = await MongoMemoryServer.create({
  binary: { version: '7.0.14' },
  instance: {},
  spawnTimeout: 60000,
});

How to prevent it

  • Install required shared libraries on slim images.
  • Pin the mongod version to one compatible with the runner OS.
  • Allow a generous start timeout on small runners.

Frequently asked questions

What causes "mongodb-memory-server "failed to start""?
The mongod binary links against libraries such as libcrypto or libcurl that a minimal runner image does not provide, so it exits at launch.
How do I fix mongodb-memory-server "failed to start"?
Provide the shared libraries mongod links against, or pin a mongod version that matches the runner OS.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card