{ }
Published on

Run Appsmith with MongoDB Locally for Internal Tools (2025 Guide)

Authors
  • avatar
    Name
    Ahmed Farid
    Twitter
    @

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

1. Prerequisites & Terminology

  • Docker Desktop 4.
  • 8 GB RAM.
  • Basic Mongo shell knowledge.
TermMeaning
Replica SetMongo high-availability cluster; a single-node RS works locally
AppsmithLow-code platform to build internal tools
PluginsAppsmith 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

  1. Datasources → + New → MongoDB.
  2. Host: mongo (Docker DNS) Port: 27017.
  3. Authentication: admin/pass123.
  4. Database Name: inventory.
  5. 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

SymptomFix
Connection refusedEnsure APPSMITH_MONGODB_URI points to mongo service, not localhost.
Replica set errorsrs.status() in shell; if absent, rerun rs.initiate() manually.
High memory usageLimit 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! 🛠️