mongo: command not found (use mongosh) MongoDB Origin: Data Last updated 5 Nov 2026

MongoDB: bash: mongo: command not found / zsh: command not found: mongo

The legacy mongo shell was removed from MongoDB 6.0+ installs; the shell is now mongosh, or MongoDB isn't installed.

Exact message you may see mongo: command not foundbash: mongo: command not foundzsh: command not found: mongomongosh: command not found/bin/sh: mongo: not found
Seen on: MongoDB Linux

Meaning

Install the shell separately (brew install mongosh, apt install mongodb-mongosh, or download), and use mongosh instead of mongo. For the server use mongod. Packages from the MongoDB repo install mongodb-org-tools for mongodump/mongorestore.

Common causes

  • MongoDB 6+ no longer ships mongo
  • Only mongod installed, no shell
  • PATH missing the MongoDB bin directory
  • Using a distro package without tools
  • Docker image without the shell

⚡ Quick fix

  1. Install mongosh and run mongosh "mongodb://localhost:27017"
  2. Add the bin directory to PATH
  3. In Docker: docker exec -it mongo mongosh

Detailed fix by platform

Linux

  1. sudo apt-get install -y mongodb-mongosh or brew install mongosh

How to diagnose

  1. Version — MongoDB 6+?
  2. Shell — mongosh installed?
  3. PATH — Bin dir?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Data. Errors that are often confused with or caused by this one (click to open):

Atlas: bad auth: Authentication failed — MongoServerError: bad auth : Authentication failed. (Atlas user / special characters in password) (MongoDB)Atlas: bad auth: Auth…BSONObj size is invalid / exceeds maximum document size (16MB) — MongoServerError: BSONObj size: 17825792 (0x1100000) is invalid. Size must be between 0 and 16793600(16MB) (MongoDB)BSONObj size is inval…command not found — bash: command not found (Linux)command not foundMongoDB Atlas: connection timed out — IP not whitelisted — MongoServerSelectionError: Could not connect to any servers in your MongoDB Atlas cluster. One common reason is that you're trying to access the database from an IP that isn't whitelisted (MongoDB)MongoDB Atlas: connec…MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017 — MongoDB: MongoServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017 (MongoDB)MongoNetworkError: co…nodemon crashed — [nodemon] app crashed - waiting for file changes before starting... (Node.js)nodemon crashedredis-server / redis-cli: command not found — Shell: bash: redis-cli: command not found / zsh: command not found: redis-server (Redis)redis-server / redis-…Sort/Group exceeded memory limit of 100 MB (allowDiskUse) — MongoServerError: Exceeded memory limit for $group, but didn't allow external sort. Pass allowDiskUse:true to opt in (MongoDB)Sort/Group exceeded m…mongo: co…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.