> Source: https://meetrix.io/store/mongodb/
> Markdown copy of that page. Cite the URL above, not this file.

[Store](https://meetrix.io/store/)  MongoDB

Self-hosted MongoDB Atlas alternative

# Self-hosted MongoDB with S3 backups on AWS

Run MongoDB on an EC2 instance in your own AWS account, with your database, user and automated daily backups to S3 set up at launch. You pay for infrastructure, not a managed per-node margin.

 [Launch on AWS](https://aws.amazon.com/marketplace/pp/prodview-q6fpxcxkl45qi)

-   Ready in 5-10 minutes
-   Daily backups to S3
-   Runs in your own account

![MongoDB database server with S3 backups on AWS by Meetrix](https://meetrix.io/assets/store/mongodb/mongodb.webp)

## What is MongoDB?

MongoDB is the leading document-oriented NoSQL database. It stores data as flexible BSON documents instead of fixed tables, which suits applications whose data shape changes often.

-   ### Document model

    Store flexible JSON-like documents without a fixed schema.

-   ### Standard drivers

    Connect from any language with the official MongoDB drivers.

-   ### MongoDB Compass

    Browse and query your data with the Compass GUI.

-   ### Daily S3 backups

    Automated backups to a bucket in your own account.

-   ### Your own instance

    Choose the region, size and network rules.

-   ### No per-node margin

    Pay EC2 and storage costs instead of managed pricing.

## What's in the Meetrix MongoDB AMI

The AMI ships MongoDB configured from your stack parameters, with backups already scheduled.

-   MongoDB with your database, user and password created at launch
-   Automated daily backups to your own S3 bucket
-   Network rules for database and SSH access
-   A CloudFormation template for your own AWS account
-   Email support from Meetrix at aws@meetrix.io

## How to set up a self-hosted MongoDB server

1.  ### Create an S3 bucket

    Make an S3 bucket in your account for the database backups.

2.  ### Launch the stack

    Subscribe on AWS Marketplace and launch the stack with your database name, user, password and bucket.

3.  ### Restrict access

    Limit DatabaseSSHLocation and SSHLocation to your own IP ranges instead of 0.0.0.0/0.

4.  ### Connect

    After 5-10 minutes, connect to the PublicIp on port 27017 with your user and password, for example from MongoDB Compass.

## Deploy on AWS

### MongoDB on AWS

An AMI on AWS Marketplace, launched into your own AWS account with a CloudFormation stack.

Deploys with

CloudFormation

Recommended size

t3.small

Backups

Daily to S3

#### Setup guides

-   [**Developer guide** Launch, connect, upgrade](https://meetrix.io/blogs/mongodb-developer-guide/)
-   [**Back up and restore MongoDB on AWS** Automated daily backups](https://meetrix.io/blogs/mongodb-aws-backup/)
-   [**Video walkthrough** Watch the deployment on YouTube](https://www.youtube.com/watch?v=QfGe0N3e0P8)

 [Launch on AWS](https://aws.amazon.com/marketplace/pp/prodview-q6fpxcxkl45qi)

## MongoDB server ports

Restrict both ports to the IP ranges that need them.

| Service | Ports | Protocol |
| --- | --- | --- |
| MongoDB | 27017 | TCP |
| SSH (administration) | 22 | TCP |

## MongoDB Atlas vs self-hosted MongoDB on EC2

|  | MongoDB Atlas | Self-hosted on EC2 |
| --- | --- | --- |
| Pricing | Usage-based, per cluster tier | EC2 and storage costs |
| Backups | Automated, billed separately | Daily to S3 with the Meetrix AMI |
| Patching and upgrades | Fully managed | Your responsibility |
| Compliance attestations | Included by Atlas | You own the audit evidence |

Self-hosting is cheaper on infrastructure, but count the engineering time it takes. [Read MongoDB Atlas vs self-hosted →](https://meetrix.io/blogs/mongodb-atlas-vs-self-hosted/)

## Video: deploy MongoDB on AWS

## MongoDB FAQ

How do I connect to MongoDB?

Use the PublicIp from the stack outputs, port 27017, and the database user, password and name you set when creating the stack.

How are backups handled?

Automated daily backups go to the S3 bucket you choose at launch. You can also use standard MongoDB backup tools for manual backups.

Is self-hosting cheaper than MongoDB Atlas?

On infrastructure, usually. But patching, monitoring and backup testing become your job, so include that time in the comparison.

Should I leave access open to 0.0.0.0/0?

No. Restrict the database and SSH source ranges to the addresses that need them.

Which instance size should I choose?

t3.small is the recommended starting point. Size up with your data and workload.

What if I hit a vCPU quota error?

Request a quota increase in the AWS Service Quotas console, then launch again.

How do I upgrade?

Back up your data, launch the stack with the new AMI version, and restore from the backup.

## MongoDB guides and articles

### [MongoDB Atlas vs Self-Hosted MongoDB on EC2: Real Costs](https://meetrix.io/blogs/mongodb-atlas-vs-self-hosted/)

Atlas pricing against EC2 costs, including engineering time.

### [How to Back Up and Restore MongoDB in AWS](https://meetrix.io/blogs/mongodb-aws-backup/)

Automated daily backups and recovery best practices.

### [MongoDB: Developer Guide](https://meetrix.io/blogs/mongodb-developer-guide/)

Launch the stack and connect to your database.

## Need a hand with MongoDB?

We build and run self-hosted databases every day, from backup strategy to replica sets. Tell us what you need.

[Contact us](https://meetrix.io/contact-us/)
