MongoDB : container mongo is unhealthy
Nobody has claimed this yet.
- Dominant language
- Shell
- Stars
- 1.3k
- Forks
- 310
- Avg merge
- 3d 12h
- Merged PRs (30d)
- 1
Description
Moved from: https://github.com/overleaf/overleaf/issues/1332#issue-2959050148
I have just run /bin/upgrade while following this issue, now while everything seems to start I cannot access the website on localhost and get errors regarding MongoDB.
Doctor output:
~/opt/overleaf master*
❯ bin/doctor
====== Overleaf Doctor ======
- Host Information
- Linux
- Output of 'lsb_release -a':
LSB Version: n/a
Distributor ID: cachyos
Description: CachyOS
Release: rolling
Codename: n/a
- Dependencies
- bash
- status: present
- version info: 5.2.37(1)-release
- docker
- status: present
- version info: Docker version 28.0.4, build b8034c0ed7
- realpath
- status: present
- version info: realpath (GNU coreutils) 9.6
- perl
- status: present
- version info: 5.040001
- awk
- status: present
- version info: GNU Awk 5.3.1, API 4.0, PMA Avon 8-g1, (GNU MPFR 4.2.2, GNU MP 6.3.0)
- openssl
- status: present
- version info: OpenSSL 3.4.1 11 Feb 2025 (Library: OpenSSL 3.4.1 11 Feb 2025)
- docker compose
- status: present
- version info: Docker Compose version 2.34.0
- Docker Daemon
- status: up
- server version: 28.0.4
====== Configuration ======
- config/version
- status: present
- version: 5.3.3
- config/overleaf.rc
- status: present
- values
- OVERLEAF_DATA_PATH: data/sharelatex
- OVERLEAF_LOG_PATH: not set, keeping logs in container
- SERVER_PRO: false
- SIBLING_CONTAINERS_ENABLED: false
- OVERLEAF_LISTEN_IP: 0.0.0.0
- OVERLEAF_PORT: 8081
- MONGO_ENABLED: true
- MONGO_IMAGE: mongo
- MONGO_VERSION: 6.0
- MONGO_DATA_PATH: data/mongo
- REDIS_ENABLED: true
- REDIS_IMAGE: redis:6.2
- REDIS_AOF_PERSISTENCE: true
- REDIS_DATA_PATH: data/redis
- NGINX_ENABLED: false
- NGINX_CONFIG_PATH: config/nginx/nginx.conf
- TLS_PRIVATE_KEY_PATH: config/nginx/certs/overleaf_key.pem
- TLS_CERTIFICATE_PATH: config/nginx/certs/overleaf_certificate.pem
- NGINX_HTTP_LISTEN_IP: 127.0.1.1
- NGINX_HTTP_PORT: 80
- NGINX_TLS_LISTEN_IP: 127.0.1.1
- TLS_PORT: 443
- GIT_BRIDGE_ENABLED: true
- config/variables.env
- status: present
- values
- SHARELATEX_FILESTORE_BACKEND: fs
- SHARELATEX_HISTORY_BACKEND: fs
- OVERLEAF_FILESTORE_BACKEND: fs
- OVERLEAF_HISTORY_BACKEND: fs
====== Warnings ======
! Detected SIBLING_CONTAINERS_ENABLED=false. When not using Sibling containers, users have full read and write access to the 'sharelatex' container resources (filesystem, network, environment variables) when running LaTeX compiles. Only use this mode in environments where all users are trusted and no isolation of users is required.
====== End ======
Additionaly here is some docker logs:
docker logs sharelatex
cannot connect to mongodb
MongoServerSelectionError: connect ECONNREFUSED 172.18.0.2:27017
at Topology.selectServer (/overleaf/node_modules/mongodb/lib/sdam/topology.js:320:38)
at async Topology._connect (/overleaf/node_modules/mongodb/lib/sdam/topology.js:204:28)
at async Topology.connect (/overleaf/node_modules/mongodb/lib/sdam/topology.js:156:13)
at async topologyConnect (/overleaf/node_modules/mongodb/lib/mongo_client.js:233:17)
at async LegacyMongoClient._connect (/overleaf/node_modules/mongodb/lib/mongo_client.js:246:13)
at async LegacyMongoClient.connect (/overleaf/node_modules/mongodb/lib/mongo_client.js:171:13)
at async main (file:///overleaf/services/web/modules/server-ce-scripts/scripts/check-mongodb.mjs:14:19) {
reason: TopologyDescription {
type: 'Unknown',
servers: Map(1) { 'mongo:27017' => [ServerDescription] },
stale: false,
compatible: true,
heartbeatFrequencyMS: 10000,
localThresholdMS: 15,
setName: null,
maxElectionId: null,
maxSetVersion: null,
commonWireVersion: 0,
logicalSessionTimeoutMinutes: null
},
code: undefined,
[Symbol(errorLabels)]: Set(0) {},
[cause]: MongoNetworkError: connect ECONNREFUSED 172.18.0.2:27017
at Socket.<anonymous> (/overleaf/node_modules/mongodb/lib/cmap/connect.js:285:44)
at Object.onceWrapper (node:events:633:26)
at Socket.emit (node:events:518:28)
at emitErrorNT (node:internal/streams/destroy:169:8)
at emitErrorCloseNT (node:internal/streams/destroy:128:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
[Symbol(errorLabels)]: Set(1) { 'ResetPool' },
[cause]: Error: connect ECONNREFUSED 172.18.0.2:27017
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1611:16) {
errno: -111,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '172.18.0.2',
port: 27017
}
}
}
*** /etc/my_init.d/500_check_db_access.sh failed with status 1
*** Killing all processes...
Mar 30 19:13:12 9b4eba7da90a syslog-ng[51]: syslog-ng shutting down; version='4.3.1'
*** Running /etc/my_init.d/000_check_for_old_bind_mounts_5.sh...
*** Running /etc/my_init.d/000_check_for_old_env_vars_5.sh...
*** Running /etc/my_init.d/00_regen_ssh_host_keys.sh...
*** Running /etc/my_init.d/100_generate_secrets.sh...
*** Running /etc/my_init.d/100_make_overleaf_data_dirs.sh...
*** Running /etc/my_init.d/100_restore_site_status.sh...
*** Running /etc/my_init.d/100_set_docker_host_ipaddress.sh...
*** Running /etc/my_init.d/10_syslog-ng.init...
Mar 30 19:13:13 9b4eba7da90a syslog-ng[51]: syslog-ng starting up; version='4.3.1'
*** Running /etc/my_init.d/200_nginx_config_template.sh...
Nginx: generating config file from template
Checking Nginx config
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Nginx: reloading config
* Reloading nginx configuration nginx
...done.
*** Running /etc/my_init.d/300_delete_old_logs.sh...
*** Running /etc/my_init.d/500_check_db_access.sh...
Checking can connect to mongo and redis
Using default settings from /overleaf/services/web/config/settings.defaults.js
Using settings from /etc/overleaf/settings.js
Set UV_THREADPOOL_SIZE=16
I am running on Cachy OS (arch) and thinking this might be some system package issue, updated everything but it does not seem to be the case. The mongo container appears to be unable to start/stuck in restarting until the version error is fixed, but I am unable to fix it in the current state.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing bin/upgrade and the MongoDB settings shown in config/overleaf.rc, then inspect the MongoDB container status and logs alongside bin/doctor output. Done means the MongoDB container is healthy, sharelatex can connect to it, and the website is accessible on the configured port.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- arch-linux, docker, mongodb, shell
- Domain
- databases, devops, infrastructure
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100