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.
StdoutInstanceError: Instance failed to start because a library is missing
or cannot be opened: "libcrypto.so.1.1"
at MongoInstance.checkErrorInLineCommon 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.
sudo apt-get update
sudo apt-get install -y libcurl4 openssl ca-certificatesRaise the start timeout and pin the version
Give mongod more time to start and pin a version known to run on the runner image.
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.