‘mongo’ is not recognized as an internal or external command

Today in this article, we will cover the below aspects for resolving the common error “mongo is not recognized”

Issue Description

Mongo command line/CLI command gives the below error,

'mongo' is not recognized as an internal or external command, operable program or batch file. 
'mongo' is not recognized as an internal or external command

This issue I found to be due to not setting up the environment variable on a machine where you have installed the MongoDB component.

Resolution

On a Windows machine, you need to set up a MongoDB environment variable.

Please follow below high-level steps required for you to fix the issue.

  • Check the file path for MongoDB installation

Usually, Mongo exe will be available in the below location,

If using MongoDB 4.0 version,

C:\Program Files\MongoDB\Server.0\bin

OR

If using MongoDB 4.2 version,

C:\Program Files\MongoDB\Server.2\bin

  • Update the System environment variable for the above paths,
mongo is not recognized as an internal or external command operable program

Note:

  • To make the variable effective, please close any existing CMD window and launch a new one.
  • Sometimes restarting may also help set up the required environment variable.

References:

That’s all! Happy coding!

Does this help you fix your issue?

Do you have any better solutions or suggestions? Please sound off your comments below.



Please bookmark this page and share it with your friends. Please Subscribe to the blog to receive notifications on freshly published(2024) best practices and guidelines for software design and development.



2 thoughts on “Resolved- mongo is not recognized as an internal or external command

    1. Rahul – Please try both the approaches discussed. Please check the location of path for utilities like Mongo exe etc and set up the environment path accordingly.

Leave a Reply

Your email address will not be published. Required fields are marked *