Fixes MongoDB containers being marked unhealthy when deploying Rocket.Chat on Coolify, which prevented Rocket.Chat from starting. The issue was caused by an outdated health check, missing hostname, and insufficient replica set initialization for modern MongoDB versions.
Problem Rocket.Chat deployments failed with: Error dependency mongodb failed to start container mongodb-xxx is unhealthy
Root Causes Health check used deprecated mongo CLI (removed in MongoDB 6.0+) MongoDB service lacked an explicit hostname Replica set initialization was unreliable (required by Rocket.Chat v8+) Health check timing was too aggressive during startup
Changes Replaced mongo with mongosh Uses db.adminCommand(‘ping’) Increased retries and added startup grace period
healthcheck: test: [“CMD”, “mongosh”, “–eval”, “db.adminCommand(‘ping’)”] interval: 10s timeout: 5s retries: 30 start_period: 40s
hostname: mongodb, ensures reliable internal DNS resolution and replica set stability.
Replica set configuration is preserved and now initializes correctly: MONGODB_REPLICA_SET_MODE=primary MONGODB_REPLICA_SET_NAME=rs0 MONGODB_INITIAL_PRIMARY_HOST=mongodb
Files Changed templates/compose/rocketchat.yaml templates/service-templates.json templates/service-templates-latest.json
https://github.com/user-attachments/assets/0689ba83-27a0-4843-a412-16699dfee65f
/claim 7941
ayush-agrawal-07-30-gmail-com
@ayush-agrawal-07-30-gmail-com
Paul Albrecht
@paul-hph