How to Self-Host MongoDB on a Linux VPS (RAM, WiredTiger & Backups)
MongoDB hosting in India is either mongod on a VPS you control or a managed cluster billed hourly. Size RAM to the working set plus indexes, run three nodes for production, bind to localhost or a private IP, and back up with mongodump and snapshots. WebJi® quotes the VPS by email.
For Indian teams choosing between a self-managed VPS, MongoDB Atlas and managed database hosting.
knowledge
- Read time
- 5 min
- Sections
- 7
- Updated
- 14 Nov 2026
- Written by
- WebJi® team
Last editorial update: 15 November 2026.
What MongoDB hosting in India means
MongoDB hosting in India comes down to three routes: mongod on a VPS you control, a managed cluster billed hourly in USD, or a host-managed database server on a monthly INR plan. There is no shared-hosting MongoDB — the database is a long-running process with its own port, memory profile and disk pattern, so it needs a machine where you can edit mongod.conf and open port 27017 to the right address only.
| Route | Who runs the database | Price shape |
|---|---|---|
| Self-managed VPS | You: install, patch, replica set, backups | Flat INR per month |
| MongoDB Atlas | MongoDB: cluster, patches, snapshots | USD per hour, per tier |
| Managed MongoDB server | The host: OS and database, with ticket support | Monthly plan, INR |
A team without a database person should price Atlas first. A team with an app already on a VPS usually keeps the database beside it and saves the egress.
Size RAM and disk around the working set
RAM is decided by the working set, not by total data size: the data and indexes MongoDB reads often enough to keep hot. If the working set fits in memory, queries avoid disk; if it does not, everything pays the disk price.
- Estimate: add data size and index size, then take the hot share. A 20 GB database with 8 GB of indexes and a 60% hot set needs about 17 GB of cache.
- WiredTiger default: the cache is the larger of 50% of (RAM − 1 GB) or 256 MB per the MongoDB manual, so 17 GB of cache means planning a 32 GB machine with room for the OS and connections.
- Disk: holds data, indexes, the oplog and snapshots; the oplog grows large on write-heavy apps, so give it its own size in the plan.
- Headroom: leave 30% free disk — a full disk stops writes and can corrupt the stand-in for a clean shutdown.
Check real numbers instead of guessing: db.serverStatus().wiredTiger.cache shows bytes currently in cache, and db.stats() shows data and index size per database.
Run a three-node replica set
Production MongoDB should be a replica set: three members give a majority for elections, while two cannot elect a primary when one is down. Even a single machine's budget can run all three members, though that protects against process failure, not the machine dying.
# /etc/mongod.conf on each node
replication:
replSetName: rs0
net:
bindIp: 127.0.0.1,10.0.0.11
rs.initiate({_id:"rs0",members:[
{_id:0,host:"10.0.0.11:27017",priority:2},
{_id:1,host:"10.0.0.12:27017"},
{_id:2,host:"10.0.0.13:27017"}]})
Wait for rs.status() to show one PRIMARY and two SECONDARY members; the member with priority 2 becomes primary. Point the application at the set, not one IP: mongodb://app:pass@10.0.0.11:27017,10.0.0.12:27017/app?replicaSet=rs0. Test failover by stopping the primary — the app should reconnect to the new primary within the driver's timeout. For real machine-failure cover, put the members on separate hosts.
Secure it with auth, bindIp and a firewall
An open MongoDB port is found by scanners within hours, and two controls do most of the work: authentication and a bind address that is not the public interface.
- Create the admin user while authorization is still off:
mongosh admin --eval 'db.createUser({user:"siteAdmin",pwd:passwordPrompt(),roles:[{role:"root",db:"admin"}]})' - Create a per-app user with readWrite on that database only; never let the app connect as root.
- Set
security.authorization: enabledin mongod.conf and restart. - Set
net.bindIp: 127.0.0.1,10.0.0.11so only local and private traffic reach the port — never 0.0.0.0. - Allow the app subnet only:
ufw allow from 10.0.0.0/24 to any port 27017 proto tcp, thenufw reload.
You know it worked when ss -lntp | grep 27017 shows the private address, and a connection attempt from outside times out instead of prompting for a password.
Back up with mongodump and snapshots
A replica set is not a backup: deleting the wrong collection replicates to every member in seconds, so keep a copy the database cannot reach.
mongodump --uri="mongodb://siteAdmin@10.0.0.11:27017/?authSource=admin" \
--gzip --archive=/backup/app-$(date +%F).gz
mongorestore --gzip --archive=/backup/app-2026-10-01.gz --nsInclude='app.*'
- Add
--oplogwhen you need point-in-time recovery on a replica set; it captures writes made during the dump. - Keep a provider disk snapshot as well, so a full restore does not depend on replaying a dump.
- Restore into a scratch instance once a month — an untested backup is only a file.
Three copies, two media, one off the server is the habit. WebJi® server backup solutions start at ₹1,300 a month for the Backup.Help app with 200 GB, before 18% GST, if you want the copy kept off the VPS.
What WebJi® hosts and how the quote works
WebJi® runs MongoDB on Linux VPS and cloud instances — the database is installed on the machine you rent, not offered as a shared database service, and there is no per-cluster Atlas-style console. Pricing depends on RAM, disk and how many replica members you want, so it is quoted by email before payment. Write to support@webji.services with the data size, index size, expected write rate and whether you need two or three nodes; support is 24/7 by email in Hindi and English with a published average first reply under 60 minutes.
For a starting point, the managed cloud tiers begin at 2 vCPU, 8 GB RAM and 100 GB for ₹5,900 a month before 18% GST, and Linux VPS plans are the other common base. An existing database can be moved as part of the setup, with the scope confirmed by email.
Atlas pricing compared with a WebJi® VPS
Atlas is priced in USD per hour and includes the operations you would otherwise do yourself, so the honest comparison is against what the same working set costs on a VPS. The Atlas figures below were read on 29 October 2026 and are not a like-for-like spec match with a VPS.
| Option | Shape | Price as printed |
|---|---|---|
| Atlas M0 | 512 MB, shared | $0, free forever |
| Atlas Flex | 5 GB, shared, usage-based | $8–$30 a month |
| Atlas M10 | 2 GB RAM, 2 vCPU, 10 GB+ | $0.08 an hour, about $57 a month |
| Atlas M30 | 8 GB RAM, 2 vCPU, 40 GB+ | $0.54 an hour |
| WebJi® Cloud Entry | 2 vCPU, 8 GB RAM, 100 GB | ₹5,900 a month, before 18% GST |
| WebJi® Cloud Pro | 8 vCPU, 32 GB RAM, 500 GB | ₹11,900 a month, before 18% GST |
The free tier is for learning, not production: 512 MB with shared CPU will not hold a working set. Past that, compare Atlas M30 against a 32 GB VPS, because both can hold a mid-size working set — Atlas wins on operations, the VPS wins on INR billing and control. The MySQL vs MongoDB comparison covers the database choice itself, and VPS hosting lists the base plans.
Frequently asked questions
How much RAM does MongoDB need?
Enough to hold the working set and indexes, plus about 1 GB for the system. WiredTiger keeps the larger of 50% of (RAM − 1 GB) or 256 MB in cache by default. Read db.serverStatus().wiredTiger.cache on the current server before you pick a size.
Can I run MongoDB on shared hosting?
No. Shared hosting is built around MySQL and does not let you run a mongod process or open port 27017. Use a VPS or a managed MongoDB service, even for a small database.
Do I need a replica set in production?
Yes, if the data matters. Three members give automatic failover and a majority for elections. Two members cannot elect a primary when one is down, which is worse than a single node with good backups.
How do I secure MongoDB on a VPS?
Enable authorization, create an app user with readWrite on one database, bind to 127.0.0.1 and the private IP, and allow 27017 only from the app subnet in ufw. Then confirm from outside that the port does not answer.
Can I host MongoDB in India with INR billing?
Yes. WebJi® installs MongoDB on a Linux VPS or cloud instance in INR, with 18% GST on the invoice, and quotes the exact size by email before payment. Atlas also has a Mumbai region but bills in USD.
Last editorial update: 15 November 2026. Prices follow the dated sources on this page; checkout confirms current charges.
Ready to get started with WebJi®?
Join 12,000+ businesses across India and overseas. INR pricing, 18% GST shown before payment and 24/7 email support in Hindi and English — average first reply under 60 minutes.