{
  "manifest_version": "1",
  "slug": "mongodb",
  "title": "MongoDB",
  "headline": "Self-host MongoDB",
  "description": "Run MongoDB 9.0 Community Edition on an exe.dev VM: access control on, transactions and change streams, nightly tested backups, and SSH tunnels.",
  "category": "databases",
  "tags": [
    "mongodb",
    "mongodb 9.0",
    "document database",
    "mongodump",
    "backups",
    "replica set",
    "compass"
  ],
  "url": "https://exe.dev/deploy/mongodb",
  "markdown_url": "https://exe.dev/deploy/mongodb.md",
  "upstream": {
    "website": "https://www.mongodb.com/products/self-managed/community-edition",
    "source": "https://github.com/mongodb/mongo",
    "docs": "https://www.mongodb.com/docs/manual/",
    "license": "SSPL-1.0"
  },
  "example_vm_name": "my-mongodb",
  "time": "10 minutes",
  "stack": [
    {
      "name": "MongoDB 9.0",
      "detail": "Community Edition from MongoDB's apt repository, a one-member replica set",
      "port": 27017,
      "data": "/var/lib/mongodb"
    },
    {
      "name": "Nightly backups",
      "detail": "mongodump of every database and user, 14 nights kept",
      "data": "~/mongodb/backups"
    }
  ],
  "delivers": [
    "MongoDB 9.0 Community Edition, started at boot, listening on localhost only, with access control on.",
    "A one-member replica set, so transactions and change streams work.",
    "An `admin` user, and an `app` database with its own user and connection string in `~/mongodb/app.env`.",
    "Nightly backups with `mongodump`, one restored with `mongorestore` and checked."
  ],
  "owner_runs_after": [
    "ssh my-mongodb.exe.xyz cat mongodb/app.env",
    "ssh -N -L 27018:localhost:27017 my-mongodb.exe.xyz"
  ],
  "deployable": true,
  "deploy": {
    "new_vm_url": "https://exe.dev/new?prompt=Set%20up%20MongoDB%20on%20this%20VM%20by%20following%20the%20exe.dev%20recipe%20at%20https%3A%2F%2Fexe.dev%2Fdeploy%2Fmongodb.md%20from%20top%20to%20bottom.%0A%0AThe%20recipe%27s%20example%20VM%20name%20is%20my-mongodb.%20This%20VM%27s%20name%20is%20the%20output%20of%20%60hostname%60%3A%20use%20it%20wherever%20the%20recipe%20writes%20my-mongodb.%20Skip%20the%20step%20that%20creates%20the%20VM%3B%20you%20are%20on%20it.%0A%0AYou%20are%20done%20when%20all%20of%20these%20are%20true.%20Check%20each%20one%20yourself%3A%0A-%20MongoDB%209.0%20Community%20Edition%2C%20started%20at%20boot%2C%20listening%20on%20localhost%20only%2C%20with%20access%20control%20on.%0A-%20A%20one-member%20replica%20set%2C%20so%20transactions%20and%20change%20streams%20work.%0A-%20An%20%60admin%60%20user%2C%20and%20an%20%60app%60%20database%20with%20its%20own%20user%20and%20connection%20string%20in%20%60~%2Fmongodb%2Fapp.env%60.%0A-%20Nightly%20backups%20with%20%60mongodump%60%2C%20one%20restored%20with%20%60mongorestore%60%20and%20checked.%0A%0ARead%20the%20whole%20recipe%2C%20including%20the%20closed%20details.%20For%20initial%20setup%2C%0Afollow%20%22Install%20by%20hand%22%20from%20top%20to%20bottom%3A%20the%20MongoDB%20repository%20and%0Aserver%2C%20the%20replica%20set%20and%20access%20control%2C%20log%20rotation%2C%20the%20app%0Adatabase%2C%20the%20backup%20timer%2C%20and%20the%20scratch-server%20restore%20test.%20The%0Awalkthrough%20sections%20are%20for%20the%20owner%20afterwards%3A%20don%27t%20import%20data%2C%0Aset%20up%20Tailscale%20or%20Docker%20access%2C%20or%20run%20the%20Restore%20or%20Update%0Ainstructions%20during%20initial%20setup.%20Never%20overwrite%20an%20existing%0A~%2Fmongodb%2F%2A.env%20file%20or%20%2Fetc%2Fmongod.keyfile.%20Leave%20the%20VM%20private%20and%0Ado%20not%20reboot.%20Don%27t%20paste%20passwords%20into%20the%20chat%3B%20say%20they%20are%20in%0A~%2Fmongodb%2Fapp.env%20and%20~%2Fmongodb%2Fadmin.env.%0A%0AFinish%20with%20the%20URLs%20I%20should%20open%20and%20these%20commands%2C%20which%20only%20I%20can%20run%2C%20from%20my%20own%20computer%20%28with%20this%20VM%27s%20name%20in%20them%29%3A%0A%20%20ssh%20my-mongodb.exe.xyz%20cat%20mongodb%2Fapp.env%0A%20%20ssh%20-N%20-L%2027018%3Alocalhost%3A27017%20my-mongodb.exe.xyz%0A",
    "terminal": "curl -fsSL https://exe.dev/deploy/mongodb/prompt.txt | ssh exe.dev new --prompt=/dev/stdin",
    "prompt": "Set up MongoDB on this VM by following the exe.dev recipe at https://exe.dev/deploy/mongodb.md from top to bottom.\n\nThe recipe's example VM name is my-mongodb. This VM's name is the output of `hostname`: use it wherever the recipe writes my-mongodb. Skip the step that creates the VM; you are on it.\n\nYou are done when all of these are true. Check each one yourself:\n- MongoDB 9.0 Community Edition, started at boot, listening on localhost only, with access control on.\n- A one-member replica set, so transactions and change streams work.\n- An `admin` user, and an `app` database with its own user and connection string in `~/mongodb/app.env`.\n- Nightly backups with `mongodump`, one restored with `mongorestore` and checked.\n\nRead the whole recipe, including the closed details. For initial setup,\nfollow \"Install by hand\" from top to bottom: the MongoDB repository and\nserver, the replica set and access control, log rotation, the app\ndatabase, the backup timer, and the scratch-server restore test. The\nwalkthrough sections are for the owner afterwards: don't import data,\nset up Tailscale or Docker access, or run the Restore or Update\ninstructions during initial setup. Never overwrite an existing\n~/mongodb/*.env file or /etc/mongod.keyfile. Leave the VM private and\ndo not reboot. Don't paste passwords into the chat; say they are in\n~/mongodb/app.env and ~/mongodb/admin.env.\n\nFinish with the URLs I should open and these commands, which only I can run, from my own computer (with this VM's name in them):\n  ssh my-mongodb.exe.xyz cat mongodb/app.env\n  ssh -N -L 27018:localhost:27017 my-mongodb.exe.xyz\n",
    "prompt_url": "https://exe.dev/deploy/mongodb/prompt.txt"
  },
  "updated": "2026-10-31",
  "verified": "2026-10-31",
  "related": [
    "postgres",
    "mysql",
    "nextjs",
    "fastapi",
    "redis",
    "n8n-2"
  ]
}
