Java – MongoDB Java driver error

MongoDB Java driver error… here is a solution to the problem.

MongoDB Java driver error

I’m having trouble with MongoDB. I installed it on my Linux server using sudo apt-get install mongodb. When I now try to connect my java driver to it, it says

Caused by: com.mongodb.MongoIncompatibleDriverException: This version
of the driver is not compatible with one or more of the servers to
which it is connected: ClusterDescription{type=STANDALONE,
type=STANDALONE, state=CONNECTED, ok=true,
version=ServerVersion{versionList=[2, 4, 10]}, minWireVersion=0,
maxWireVersion=0, maxDocumentSize=16777216,

My version of

mongoDB on the server seems to be older than my driver version.
My java driver version is 3.6
mongo-version shows 2.4

How do I fix this?


If you’re using Docker to wrap your database, I recommend changing your ubuntu version to 16.04LTS, and then your mongod will install 2.6.10 by default.

Running with java Driver is enough, no need to get 3.x.

This is Dockerfile:

FROM ubuntu:16.04

RUN apt-get update && apt-get install -yq mongodb && apt-get clean && rm -rf /var/lib/apt/lists/*

ENTRYPOINT mongod --dbpath /data/db --rest

Related Problems and Solutions