How to Check the MongoDB Version
You can check the MongoDB version from the command line, MongoDB Shell, server startup logs, MongoDB Compass, or a running Docker container. The correct method depends on whether you want the installed server binary version, the shell version, or the version of the server to which you are connected.
Check the Installed MongoDB Server Version
Run mongod --version to display the version of the installed MongoDB Server binary. This command does not require the database server to be running.
mongod --version
The output normally includes the MongoDB version, Git version, OpenSSL information, memory allocator, build environment, and target architecture.
db version vX.Y.Z
Build Info: {
"version": "X.Y.Z",
"gitVersion": "...",
"modules": [],
"allocator": "...",
"environment": {
"distarch": "...",
"target_arch": "..."
}
}
If the command is not recognized, MongoDB may not be installed, or its bin directory may not be included in the system PATH.
Check MongoDB Version on Windows Command Prompt
Open Command Prompt and run the following command when the MongoDB executable directory is already available in PATH.
mongod --version
You can also run the executable by using its complete installation path. Replace the directory in this example with the version installed on your computer.
"C:\Program Files\MongoDB\Server\<version>\bin\mongod.exe" --version
To find whether the mongod executable is available in PATH, run:
where mongod
Check MongoDB Version in Windows PowerShell
In PowerShell, the same server-version command can be used:
mongod --version
To locate the executable through PowerShell, run:
Get-Command mongod
Check MongoDB Version on Ubuntu and Other Linux Systems
Open a terminal and run mongod --version to check the installed MongoDB Server binary.
mongod --version
To check whether the executable is available and identify its location, use:
command -v mongod
On systems that use systemd, you can also inspect the service status. This confirms whether the service is installed and running, although the displayed status does not always include the complete server version.
sudo systemctl status mongod
In Ubuntu, run the following command to start Mongo Daemon.
sudo service mongod start
Check MongoDB Version on macOS
Run the following command in Terminal to display the installed MongoDB Server version:
mongod --version
If MongoDB was installed with Homebrew, you can inspect the installed package information with:
brew list --versions mongodb-community
The Homebrew package version identifies the installed package. Use mongod --version when you need the version reported directly by the server executable.
MongoDB Version Shown When the Server Starts
MongoDB writes its version to the startup log when the server process begins. Look for a line similar to db version v4.0.3. The following older example shows where the version appeared in MongoDB 4.0 startup output.
Windows
C:\>"C:\Program Files\MongoDB\Server\4.0\bin\mongod.exe"
2018-10-10T11:02:43.496+0530 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2018-10-10T11:02:43.799+0530 I CONTROL [initandlisten] MongoDB starting : pid=11716 port=27017 dbpath=C:\data\db\ 64-bit host=DESKTOP-QRVE3I1
2018-10-10T11:02:43.800+0530 I CONTROL [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2018-10-10T11:02:43.801+0530 I CONTROL [initandlisten] db version v4.0.3
2018-10-10T11:02:43.804+0530 I CONTROL [initandlisten] git version: 7ea530946fa7880364d88c8d8b6026bbc9ffa48c
2018-10-10T11:02:43.804+0530 I CONTROL [initandlisten] allocator: tcmalloc
Startup log formatting differs between MongoDB releases. Search the output for fields such as version, buildInfo, or db version.
Check the MongoDB Shell Version with mongosh
Current MongoDB installations commonly use MongoDB Shell, named mongosh. Run the following command to check the shell application’s version:
mongosh --version
This reports the mongosh version, not necessarily the version of the MongoDB Server to which it connects. The shell and server can have different version numbers.
MongoDB Version Shown by the Legacy mongo Shell
Older MongoDB installations may include the legacy mongo shell. When it starts, it displays both the shell version and the connected MongoDB Server version.
Windows
C:\>"C:\Program Files\MongoDB\Server\4.0\bin\mongo.exe"
MongoDB shell version v4.0.3
connecting to: mongodb://127.0.0.1:27017
Implicit session: session { "id" : UUID("fde958c1-c5e8-444b-87df-eec09d18cec4") }
MongoDB server version: 4.0.3
The first version in this example belongs to the shell executable. The final version belongs to the MongoDB Server running at 127.0.0.1:27017.
Check the Connected MongoDB Server with db.version()
After connecting with mongosh or the legacy Mongo shell, run db.version(). This method reports the version of the connected MongoDB Server rather than the locally installed shell.
db.version()
X.Y.Z
This is useful when the shell connects to a remote server, replica set, managed deployment, or containerized MongoDB instance.
Windows

Get Detailed MongoDB Build Information
Use db.runCommand({ buildInfo: 1 }) when you need more than the version number. The result can include the exact server version, Git revision, supported modules, JavaScript engine, allocator, and build environment.
db.runCommand({ buildInfo: 1 })
A shorter alternative available in the shell is:
db.serverBuildInfo()
Access to server information can depend on the connected user’s privileges and the deployment configuration.
Check MongoDB Version in Docker
To inspect the MongoDB binary inside a running container, replace mongodb-container with the container name or ID:
docker exec mongodb-container mongod --version
You can also connect to the running server through mongosh and call db.version():
docker exec -it mongodb-container mongosh --eval "db.version()"
Do not rely only on the Docker image tag. A floating tag may point to a different release after an image pull. Checking the binary or connected server gives the version actually running in the container.
Check MongoDB Version in MongoDB Compass
Connect to the deployment in MongoDB Compass and open the connection or deployment information shown by the application. Compass can display server details for the active connection. The exact location and label may differ between Compass releases.
For a result that is independent of the Compass interface, open the embedded shell when available and run:
db.version()
MongoDB Server Version, Shell Version, and Feature Compatibility Version
MongoDB exposes several version-related values, and they answer different questions:
| Value | What it identifies | How to check it |
|---|---|---|
| MongoDB Server binary version | The installed mongod executable | mongod --version |
| Connected server version | The MongoDB Server handling the current connection | db.version() |
| MongoDB Shell version | The locally installed mongosh application | mongosh --version |
| Feature Compatibility Version | The compatibility setting that controls availability of certain server features | db.adminCommand({ getParameter: 1, featureCompatibilityVersion: 1 }) |
The Feature Compatibility Version is not a replacement for the server version. It is a separate administrative setting commonly checked during or after an upgrade.
db.adminCommand({
getParameter: 1,
featureCompatibilityVersion: 1
})
Fix “mongod Is Not Recognized” or “Command Not Found”
If mongod --version fails, check these common causes:
- MongoDB Server is not installed on the computer.
- Only MongoDB Compass or
mongoshis installed, without the server package. - The MongoDB
bindirectory is not included inPATH. - The executable is installed under a version-specific directory.
- The command is being run on the host while MongoDB exists only inside a container.
On Windows, use where mongod. On Linux or macOS, use command -v mongod. If no path is returned, locate the installation directory or verify that MongoDB Server is installed.
MongoDB Version Check FAQs
How do I check whether MongoDB is installed in CMD?
Run mongod --version in Command Prompt. You can also run where mongod to locate the executable. If both commands fail, MongoDB Server may not be installed or its bin directory may not be in PATH.
What command shows the connected MongoDB Server version?
Connect with mongosh and run db.version(). It returns the version of the server handling that connection.
Why are the mongosh and MongoDB Server versions different?
mongosh is a separate client application. It can connect to a MongoDB Server whose release number differs from the shell version, provided the combination is supported.
How do I check the MongoDB version inside Docker?
Run docker exec <container> mongod --version to inspect the binary, or execute db.version() through mongosh inside the running container.
How can I find the latest available MongoDB release?
Check the official MongoDB release documentation or version history before installing or upgrading. The newest available release can change, and production upgrades should also account for compatibility requirements and supported upgrade paths.
MongoDB Version Tutorial QA Checklist
- Confirm that
mongod --versionis described as the installed server binary version. - Confirm that
mongosh --versionis not presented as the connected server version. - Verify that
db.version()is run only after connecting to a MongoDB deployment. - Keep legacy
mongoshell examples clearly identified as older examples. - Do not treat Feature Compatibility Version as the MongoDB Server release number.
- Use placeholders rather than claiming a specific release is the latest without current verification.
Summary of MongoDB Version Commands
Use mongod --version to inspect the installed MongoDB Server executable, mongosh --version to inspect MongoDB Shell, and db.version() to identify the server handling the current connection. For additional build details, run db.runCommand({ buildInfo: 1 }). In this MongoDB Tutorial, these methods cover Windows, Ubuntu, Linux, macOS, Docker, MongoDB Compass, current mongosh installations, and older Mongo shell environments.
TutorialKart.com