How to Set Up MongoDB Community Server Locally in MacOS

Last updated on: by Digamber

In this tutorial, i will teach you how to set up MongoDB community server in MacOS locally and run MongoDB Compass GUI to store and manage data for Node/Express js based frontend applications.

MongoDB Community Server is a free and open-source version of the popular NoSQL database system, MongoDB.

It is designed for developers and small-scale deployments and offers dev rich and intuitive features for saving and querying data.

MongoDB Community Server comes with magically features, those are:

Document-oriented: MongoDB stores data in flexible, JSON-like documents, making it easy to work with dynamic and evolving data structures.

Scalable and High-performance: MongoDB is designed to scale horizontally across multiple servers, allowing it to handle large volumes of data and high traffic loads efficiently.

Rich query language: MongoDB supports a powerful query language that allows for complex queries, including ad-hoc queries, indexing, sorting, and aggregations.

Replication and high availability: MongoDB provides built-in support for replication, allowing you to create replica sets for data redundancy and high availability.

Sharding: MongoDB supports horizontal data partitioning through sharding, enabling you to distribute data across multiple servers for improved performance and scalability.

Flexible data model: With MongoDB, you can store heterogeneous data structures within the same collection, making it easy to represent complex relationships and hierarchies.

Set Up MongoDB Community + MongoDB Compass GUI in MacOS

Database is used to store the data. In our case, we are using MongoDB Compass GUI and MongoDB Community versions.

Following process is for MacOS:

1. Download MongoDB Community Server tgz package. :-

2. Go to your Users directory.

3. Create a “data/db” folder in your system’s User folder.

e.g My Users folder name is d5

— Inside the data/db folder all your MongoDB related files or data go.

4. Open the new tab with “db” folder using the “New Terminal at Folder”

5. Check the present working directory using “pwd” command.

Copy the pwd present working directory path

6. Copy the “pwd” “present working directory” path.

7. Unzip community server.

8. Get into the main “community server folder”, Open the “bin” folder by right clicking and selecting “New Terminal at Folder”

9. On the terminal type, type the: ./mongod command, followed by –dbpath tag just after type pwd path that you obtained earlier /Users/d5/data/db.

/mongod --dbpath /Users/{your_system's_user_name}/data/db

Ensure that you removed the “{}” curly braces around the system name!

10. Download the MongoDB Compass GUI.

11. Click on Connect button, make sure to follow the above process before you start the MongoDB Compass GUI.

Else it will throw following error in MongoDB Compass GUI:

How to Set Up MongoDB Community Server Locally in MacOS

connect ECONNREFUSED″ error

12. On the successful invocation of MongoDB Compass GUI. Click on the “Databases” button, a new modal will popup.

Enter your MongoDB database and collection name then click on “Create Database”.

MongoDB database and collection name

Now, you are ready to use MongoDB database to store the data.


MongoDB Community Server is available for various operating systems, including Windows, macOS, and Linux. It can be downloaded from the official MongoDB website, and the documentation and resources are also provided to help users get started with the database. - Tamso Ma Jyotirgamaya

A Full-stack developer with a passion to solve real world problems through functional programming.