- Published on
Run Appsmith with MongoDB Locally for Internal Tools (2025 Guide)
- Authors
- Name
- Ahmed Farid
- @
IMPORTANT
Starting Appsmith 1.12 you can bring your own MongoDB instead of the embedded one—ideal for performance and backups.
This tutorial shows how to spin up Appsmith + MongoDB locally with Docker Compose and build an internal admin panel connected to your dev database.
Table of Contents
- Table of Contents
- 1. Prerequisites & Terminology
- 2. Project Structure
- 3. Docker Compose
- 4. Initialize Replica Set
- 5. Start the Stack
- 6. Connect Sample Database
- 7. Create Mongo Datasource in Appsmith
- 8. Build CRUD Page in Minutes
- 9. Hot-Reload Dev Cycle
- 10. Backup & Restore Mongo Volume
- 11. Troubleshooting
- 12. Going Further
- 13. Conclusion
1. Prerequisites & Terminology
- Docker Desktop 4.
- 8 GB RAM.
- Basic Mongo shell knowledge.
Term | Meaning |
---|---|
Replica Set | Mongo high-availability cluster; a single-node RS works locally |
Appsmith | Low-code platform to build internal tools |
Plugins | Appsmith connectors (Mongo plugin uses official driver) |
2. Project Structure
appsmith-local/
docker-compose.yml
mongo-init.js
3. Docker Compose
docker-compose.yml
:
version: '3.9'
services:
mongo:
image: mongo:7
container_name: local-mongo
restart: unless-stopped
volumes:
- mongo-data:/data/db
- ./mongo-init.js:/docker-entrypoint-initdb.d/init.js:ro
environment:
- MONGO_INITDB_ROOT_USERNAME=admin
- MONGO_INITDB_ROOT_PASSWORD=pass123
ports:
- '27017:27017'
appsmith:
image: appsmith/appsmith-ce
container_name: local-appsmith
restart: unless-stopped
ports:
- '8080:80'
environment:
- APPSMITH_MONGODB_URI=mongodb://admin:pass123@mongo:27017/appsmith?authSource=admin&replicaSet=rs0
- APPSMITH_REDIS_URL=redis://appsmith-redis:6379
depends_on:
- mongo
- redis
redis:
image: redis:7-alpine
container_name: appsmith-redis
restart: unless-stopped
volumes:
mongo-data:
Key points:
- We mount
mongo-init.js
to create a single-node replica set—Appsmith driver requires it. - Expose Appsmith on
localhost:8080
.
4. Initialize Replica Set
mongo-init.js
:
rs.initiate({
_id: 'rs0',
members: [{ _id: 0, host: 'mongo:27017' }],
})
Docker copies this and executes on first boot.
5. Start the Stack
docker compose up -d
Visit http://localhost:8080
and create the admin account.
NOTE
Apple-silicon Macs: use --platform linux/amd64
flag for mongo image or switch to mongodb/enterprise-server
multi-arch.
6. Connect Sample Database
Seed sample inventory database:
docker exec -it local-mongo mongosh -u admin -p pass123 --eval "use inventory; db.products.insertMany([{name:'MacBook',qty:4},{name:'iPhone',qty:10}])"
7. Create Mongo Datasource in Appsmith
Datasources → + New → MongoDB
.- Host:
mongo
(Docker DNS) Port:27017
. - Authentication: admin/pass123.
- Database Name:
inventory
. - SSL: disabled (local). Save & Test → Success.
8. Build CRUD Page in Minutes
- Click + next to datasource → Generate Page.
- Select
products
collection. - Appsmith scaffolds table widget with search, form modal.
- Hit Deploy to test edits; changes persist in Mongo.
9. Hot-Reload Dev Cycle
Changes in widgets reflect instantly. If you tweak docker-compose.yml
, run:
docker compose down && docker compose up -d --build
10. Backup & Restore Mongo Volume
docker run --rm -v mongo-data:/data/db -v "$PWD":/backup alpine tar czf /backup/mongo-backup.tgz /data/db
To restore: swap czf
with xzf
.
11. Troubleshooting
Symptom | Fix |
---|---|
Connection refused | Ensure APPSMITH_MONGODB_URI points to mongo service, not localhost . |
Replica set errors | rs.status() in shell; if absent, rerun rs.initiate() manually. |
High memory usage | Limit Mongo memory via --wiredTigerCacheSizeGB 0.25 . |
12. Going Further
- Wire Oauth2 (GitHub) for Appsmith login.
- Run stack on k3d for near-prod parity.
- Enable SSL: add Traefik + self-signed cert.
13. Conclusion
You now have a local Appsmith environment backed by MongoDB, ready to craft powerful internal tools with zero boilerplate. Happy building! 🛠️