Docs Menu
Docs Home
MongoDB Manual
/ / /

Install MongoDB Community on macOS using .tgz Tarball

On this page

  • Overview
  • Considerations
  • Install MongoDB Community Edition
  • Run MongoDB Community Edition
  • Additional Information


MongoDB 8.0 Release Candidates

MongoDB 8.0 binaries are currently available only as release candidates. Release candidates can be used for early testing of new features, but are not suitable for production deployments.

This version of the manual is for an upcoming release and is currently a work in progress.

Use this tutorial to manually install MongoDB 8.0 Community Edition on macOS using a downloaded .tgz tarball.

This tutorial installs MongoDB 8.0 Community Edition. To install a different version of MongoDB Community, use the version drop-down menu in the upper-left corner of this page to select the documentation for that version.

While MongoDB can be installed manually via a downloaded .tgz tarball as described in this document, it is recommended to use the brew package manager on your system to install MongoDB if possible. Using a package manager automatically installs all needed dependencies, provides an example mongod.conf file to get you started, and simplifies future upgrade and maintenance tasks.

See Install MongoDB using the brew Package Manager for instructions.

When you use the .tgz package to install the server, you need to follow the mongosh installation instructions to download and install mongosh separately.

MongoDB 8.0 Community Edition supports macOS 11 or later.

For more information, see Platform Support.

Before deploying MongoDB in a production environment, consider the Production Notes document which offers performance considerations and configuration recommendations for production MongoDB deployments.

To manually install MongoDB Community Edition from the .tgz, select the tab that corresponds with your Mac's processor and complete the following steps:

ulimit Considerations
Most Unix-like operating systems limit the system resources that a process may use. These limits may negatively impact MongoDB operation, and should be adjusted. See UNIX ulimit Settings for the recommended settings for your platform.


If the ulimit value for number of open files is under 64000, MongoDB generates a startup warning.

Follow these steps to run MongoDB Community Edition. These instructions assume that you are using the default settings.


Before you start MongoDB for the first time, you must create the directory to which the mongod process will write data.

For example, to create the ~/data/db directory:

sudo mkdir -p ~/data/db

You must also create the directory in which the mongod process will write its log file:

For example, to create the ~/data/log/mongodb directory:

sudo mkdir -p ~/data/log/mongodb

Ensure that the user account running mongod has read and write permissions for these two directories. If you are running mongod as your own user account, and you just created the two directories above, they should already accessible to your user. Otherwise, you can use chown to set ownership, substituting the appropriate user:

sudo chown <user> ~/data/db
sudo chown <user> ~/data/log/mongodb

To run MongoDB, run the mongod process at the system prompt, providing the two parameters dbpath and logpath from above, and the fork parameter to run mongod in the background. Alternatively, you may choose to store the values for dbpath, logpath, fork, and many other parameters in a configuration file.

Run the mongod process at the system prompt, providing the three necessary parameters directly on the command-line:

mongod --dbpath ~/data/db --logpath ~/data/log/mongodb/mongo.log --fork

Run the mongod process at the system prompt, providing the path to a configuration file with the config parameter:

mongod --config /usr/local/etc/mongod.conf


macOS Prevents mongod From Opening

macOS may prevent mongod from running after installation. If you receive a security error when starting mongod indicating that the developer could not be identified or verified, do the following to grant mongod access to run:

  • Open System Preferences

  • Select the Security and Privacy pane.

  • Under the General tab, click the button to the right of the message about mongod, labelled either Open Anyway or Allow Anyway depending on your version of macOS.


Verify that MongoDB has started successfully:

ps aux | grep -v grep | grep mongod

If you do not see a mongod process running, check the logfile for any error messages.


Start a mongosh session on the same host machine as the mongod. You can run mongosh without any command-line options to connect to a mongod that is running on your localhost with the default port of 27017:


For more information on connecting using mongosh, such as to connect to a mongod instance running on a different host and/or port, see the mongosh documentation.

To help you start using MongoDB, MongoDB provides Getting Started Guides in various driver editions. See Getting Started with MongoDB for the available editions.

By default, MongoDB launches with bindIp set to, which binds to the localhost network interface. This means that the mongod can only accept connections from clients that are running on the same machine. Remote clients will not be able to connect to the mongod, and the mongod will not be able to initialize a replica set unless this value is set to a valid network interface.

This value can be configured either:

  • in the MongoDB configuration file with bindIp, or

  • via the command-line argument --bind_ip


Before you bind your instance to a publicly-accessible IP address, you must secure your cluster from unauthorized access. For a complete list of security recommendations, see Security Checklist. At minimum, consider enabling authentication and hardening network infrastructure.

For more information on configuring bindIp, see IP Binding.

← Install on macOS