To start the MongoDB service manually, run the mongod process directly from the command line with the options and configuration you need.
Syntax
mongod [options]
Commands
Task | Description |
|---|---|
Start | To manually start the MongoDB process, run the |
Status | To manually check the status of a running MongoDB process, use the |
Stop | To manually stop the MongoDB process, run the |
For the full list of options, see the mongod reference.
Compatibility
On self-managed deployments of MongoDB Enterprise and MongoDB Community installed on Linux-based or macOS operating systems, you can manually manage the MongoDB process through mongod, and other commands.
Note
Running MongoDB on Windows
On Windows, you manage MongoDB as a Windows Service rather than by running mongod directly. Windows does not support the --fork option. Register the service with mongod.exe rather than starting the process from the command line. To learn more, see Run the MongoDB Service on Windows.
Behavior
User Privileges
When you manually start the MongoDB process, it executes as the user that runs the mongod command.
This user must have read and write access to the data and the log directories. If MongoDB runs as a user who does not have these privileges, it exits with an error.
Data Directory
Before you start the MongoDB process, ensure that the data and log directories exist. To create the /path/to/dataDir and /path/to/logs directories, run the following commands:
sudo mkdir -p /path/to/dataDir sudo mkdir -p /path/to/logs
Configuration
You can configure the MongoDB process through command-line options or through a configuration file. If you plan to run MongoDB for a long period of time or need it to always run with specific options, use a configuration file.
For example:
storage: dbPath: /path/to/dataDir systemLog: destination: file path: /path/to/logs logAppend: true net: port: 27017 bindIp: 127.0.0.1
The user MongoDB runs as must have read access to the configuration file and read and write access to the dbPath and path directories.
Important
Set bindIp to 127.0.0.1 to restrict connections to the local machine. To accept remote connections, set bindIp to a private or internal network interface.
Secure the deployment before you bind to a publicly-accessible address. To learn more, see Security Checklist for Self-Managed Deployments.
Examples
Start MongoDB
To start the mongod process, run the following command:
mongod --config /path/to/mongod.conf
mongod --dbpath /path/to/dataDir --logpath /path/to/logs
On Linux-based operating systems, you can use the --fork option to start MongoDB as a background process.
Show MongoDB Status
To check the status of a running mongod process, use mongosh to run the serverStatus command:
mongosh --quiet --eval "db.runCommand( { serverStatus: 1, none: 1, mem: 1 } )"
{ host: 'example', version: '9.1.0', process: 'mongod', pid: Long('71115'), uptime: 61, uptimeMillis: Long('61213'), uptimeEstimate: Long('61'), localTime: ISODate('2026-10-02T16:57:13.762Z'), ok: 1, '$clusterTime': { clusterTime: Timestamp({ t: 1790960233, i: 1 }), signature: { hash: Binary.createFromBase64('AAAAAAAAAAAAAAAAAAAAAAAAAAA=', 0), keyId: Long('0') } }, operationTime: Timestamp({ t: 1790960233, i: 1 }) }
Stop MongoDB
To stop the MongoDB process, run mongod with the --shutdown option, or connect to the server with mongosh and run the db.shutdownServer() method.
To stop the MongoDB process from mongosh, run the db.shutdownServer() method on the admin database:
mongosh admin --quiet --eval "db.shutdownServer()"
On deployments with authorization enabled, you can run db.shutdownServer() only when authenticated to the admin database. On deployments without authentication enabled, you can also run it through the localhost interface.