The MongoDB Node.js driver refuses an old server because of its wire version
Your error
Server at localhost:27017 reports wire version 8, but this version of the driver requires at least 9 (MongoDB 4.4).2 more lines it can showFix it fast
Most common cause, 1 of 2Driver 7.6+ or Mongoose 9.10+ meets a MongoDB 4.2 server
The lasting fix is a server on 4.4 or newer.
# stay on 4.2 for now: last releases before the cut
npm install mongodb@7.5.0 # apps that use the driver directly
npm install mongoose@9.9.5 # apps that use Mongoose (depends on mongodb ~7.5)Short answer
The message Server at host reports wire version 8, but this version of the driver requires at least 9 (MongoDB 4.4) means the server is older than the driver allows. mongodb 7.6.0 and Mongoose 9.10.0 dropped MongoDB 4.2; mongodb 6.17.0 and Mongoose 8.16.0 dropped 4.0. Upgrade the server one major at a time, or pin the older client meanwhile.
Which cause do you have?
List every copy of the driver in the project and which package pulled it in, then read the number in brackets at the end of the error. MongoDB 4.4 in brackets is cause 1; MongoDB 4.2 is cause 2.
npm ls mongodb mongooseThen find the line you see in this list and open its fix:
- 1Driver 7.6+ or Mongoose 9.10+ meets a MongoDB 4.2 server
The error ends with requires at least 9 (MongoDB 4.4), and npm ls shows mongodb 7.6.0 or newer - 2Driver 6.17+ or Mongoose 8.16+ meets a MongoDB 4.0 server
The error ends with requires at least 8 (MongoDB 4.2), and npm ls shows a mongodb 6.x release from 6.17.0 on
What does the error look like?
Server at localhost:27017 reports wire version 8, but this version of the driver requires at least 9 (MongoDB 4.4).Server at localhost:27017 reports wire version 7, but this version of the driver requires at least 8 (MongoDB 4.2).MongoCompatibilityError
Cause 1 of 2
Driver 7.6+ or Mongoose 9.10+ meets a MongoDB 4.2 server
You seeThe error ends with requires at least 9 (MongoDB 4.4), and npm ls shows mongodb 7.6.0 or newer
Check
The driver needs at least MongoDB 4.4 since release 7.6.0, which throws an error when it connects to a 4.2 or older server. Mongoose 9.10.0 moved to that driver, so a routine Mongoose update inside the 9.x range can break an app that has always run on 4.2.
npm ls mongodb
grep -n '"mongoose"\|"mongodb"' package.jsonFix
The lasting fix is a server on 4.4 or newer. MongoDB's upgrade guides require going through each major series in turn (4.2, 4.4, 5.0 and onward), each with its own featureCompatibilityVersion step. Until that is done, pin the last client release that still accepts 4.2.
# stay on 4.2 for now: last releases before the cut
npm install mongodb@7.5.0 # apps that use the driver directly
npm install mongoose@9.9.5 # apps that use Mongoose (depends on mongodb ~7.5)Verify
npm ls shows mongodb 7.5.x and the app connects without the compatibility error. After the server upgrade, remove the pin.
npm ls mongodb && node app.jsConfirmed by github.com
Cause 2 of 2
Driver 6.17+ or Mongoose 8.16+ meets a MongoDB 4.0 server
You seeThe error ends with requires at least 8 (MongoDB 4.2), and npm ls shows a mongodb 6.x release from 6.17.0 on
Check
Release 6.17.0 of the Node.js driver removed MongoDB 4.0, so any 6.17 or later build refuses a 4.0 or older server. Mongoose 8.16.0 switched to that driver line, and every later 8.x release keeps the newer driver, so moving to Mongoose 9 does not help either.
npm ls mongodbFix
Upgrade the server through 4.2 and 4.4 at minimum, in order. As a stopgap, hold the client at the last 4.0-capable release: mongodb 6.16.0, or Mongoose 8.15.2, which depends on mongodb ~6.16.0.
npm install mongodb@6.16.0
# or, for Mongoose projects
npm install mongoose@8.15.2Verify
The app connects, and npm ls lists only mongodb 6.16.x. Plan the server upgrade before removing the pin.
npm ls mongodbConfirmed by github.com
How do I stop it coming back?
- Write the minimum MongoDB server version next to the Mongoose or driver version in the README, and check it when Renovate or Dependabot opens an update.
- Use an exact version or a lockfile for mongoose and mongodb so a fresh install on CI cannot jump past your server's floor.
- Run the test suite in CI against the same MongoDB major version as production, using that version's Docker image.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.