For AI agents: a documentation index is available at https://www.mongodb.com/docs/llms.txt — markdown versions of all pages are available by appending .md to any URL path.
Docs Menu

Run the MongoDB Service with Homebrew

MongoDB provides a Homebrew tap that allows you to install MongoDB Enterprise and MongoDB Community through the brew package manager. If you installed MongoDB on your macOS system with these formulae, you can also manage the mongod process as a service through the brew services command.

brew services <cmd> mongodb-enterprise[@VERSION]
Command
Description

info

Shows the status of the MongoDB service.

restart

Stops the MongoDB service if running, starts it again, and then re-registers it to start at login or boot.

run

Starts the MongoDB service. Does not register it to start at login or boot.

start

Starts the MongoDB service and registers it to start at login or boot.

stop

Stops the MongoDB service and removes it from the registry of services to start at login or boot.

IMPORTANT:

To stop the process but keep it registered to start on login or boot, use the --keep option.

On self-managed deployments of MongoDB Enterprise and MongoDB Community installed on macOS through Homebrew, you can manage the mongod process as a Homebrew service through the brew services command.

For details on supported platforms, see:

Some Homebrew services commands, like start, stop, and restart interact with a registry that controls persistent services through launchd.

Run these commands with user-level privileges to update a per-user launchd agent. Use the following command to update the registry for the current user and configure it to stop the MongoDB service when you log out and restart it when you log back in:

brew services start mongodb-community@9.0

Use this behavior in development only when one user works on the system. In multi-user environments, where every user needs access to MongoDB, this configuration prevents other users from reaching the database. To configure the registry to keep MongoDB running after the user logs out and to launch it on startup rather than login, run these commands with sudo:

sudo brew services start mongodb-community@9.0

This configures the registry to start mongod on boot, rather than waiting for a specific user to log in.

Homebrew allows you to install multiple versions of a particular package on an individual system. If you start a service without specifying the version, Homebrew starts the latest version available.

brew services <cmd> mongodb-enterprise@9.0

Use the versioned formula syntax when you register the MongoDB service with launchd. This syntax ensures that Homebrew continues to start the MongoDB service with the specified version until you are ready to transition to the next major or minor release.

brew services directs the mongod log messages to a log file in the Homebrew prefix. The default log file is $(brew --prefix)/var/log/mongodb/mongo.log.

The following examples manage the Homebrew service for MongoDB Enterprise 9.0.

To start the MongoDB service for the current session, run the following command:

brew services run mongodb-enterprise@9.0

If you also want to start MongoDB for the current session and ensure that it restarts on login, see Start MongoDB on Login.

To show the status of the MongoDB service, run the following command:

brew services info mongodb-enterprise@9.0
mongodb-enterprise (sh.brew.mongodb-enterprise)
Running: true
Loaded: true
Schedulable: false
User: user.name
PID: 1845

To stop the MongoDB service and remove it from the startup registry, run the following command:

brew services stop mongodb-enterprise@9.0

To restart the mongod process, run the following command:

brew services restart mongodb-enterprise@9.0

This command also re-registers the Homebrew service to start on login.

To start the MongoDB service and register it with Homebrew to start on login, run the following command:

brew services start mongodb-enterprise@9.0

To start the MongoDB service at boot, run the preceding command with sudo.

To start MongoDB only for the current session and have it shut down when you log out or reboot, see Run MongoDB.

To show the mongod log messages, run the following command:

tail $(brew --prefix)/var/log/mongodb/mongo.log
{"t":{"$date":"2026-09-25T18:08:46.214+00:00"},"s":"I", "c":"STORAGE", "id":4615611, "ctx":"initandlisten", "msg":"MongoDB starting", "attr":{"pid":15432,"port":27017,"dbPath":"/usr/local/var/mongodb","architecture":"64-bit","host":"mac"}}
{"t":{"$date":"2026-09-25T18:08:46.214+00:00"},"s":"I", "c":"CONTROL", "id":51765, "ctx":"initandlisten", "msg":"Operating System", "attr":{"os":{"name":"macOS","version":"15.0"}}}