New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot connect to mongodb (user error?) #1188
Comments
And what do mongodb logs say? |
That would be helpful. Sorry. Mongo Container Logs:
|
I recently encounter this too. So I just give you a reminder. Overleaf is doing rebranding now(scheduled to release for overleaf 5.0), which means some env var called |
Can confirm the issue. The provided
Results in:
|
Why not use toolkit? http://github.com/overleaf/toolkit Use toolkit is a better solution, if you use direct docker-compose yml file, you need to run this first:
|
Thanks for the feedback. However, I want to use the docker compose version. Your provided intructions do not fix the issue. Same error message appears. |
Oh, I got. Currently, Overleaf is doing rebranding, which means all environment var starting with You need to replace these. Or you need to build your sharelatex image by your own. I am developing overleaf recently, but I use my self built image, so everthing works. To sum up, Currently you can only use toolkit, using that docker-compose.yml file is only for developer. Btw, you also need to init mongo as what I say above. |
Overleaf toolkit use dockerhub's image, which is still v4.2, but this file: https://raw.githubusercontent.com/overleaf/overleaf/main/docker-compose.yml is used for overleaf v5.0+, so you need to use that toolkit, in order to get support and easier upgrade. If you insist on using docker-compose.yml, you need to deal with upgrade manully, such as:
|
This week has been brutal at work, so I haven't had any time to mess about with this. Hopefully can make some time to work on it this weekend.
I didn't realize that this had happened yet. I will give it a look. I see you posted a docker compose file farther down.
Personally, because I already run all of my other containers through Portainer.
Hopefully, I will have some time to try this tonight. |
These lines work well! Thanks a lot. |
|
I have the same problem as above, doesn't work for me... Still getting the same error |
Date: 14.3.2024 I managed to make it work in Windows 11 with WSL 2 and Docker Desktop, had to finish following steps: Modify original docker compose (https://github.com/overleaf/overleaf/blob/main/docker-compose.yml):
I could not make following code work in Windows, so code above is the same as below but broken in steps:
|
Hi, I managed to make it work as well, but under Linux. First of all, I built the sharelatex docker image myself using the Makefile in server-ce/ this repository (https://github.com/overleaf/overleaf/blob/main/server-ce/Makefile). I also had to modify the mongo command, just as mentioned in some comments before:
Then:
Lastly: Hope this helps! |
I have encountered the same issue and have been unable to resolve it. I have already used a new Docker Compose file to create Docker containers, but I still encounter the same problem. |
Referring to the answers above and the methods in other places, I have changed the file to the following one so that it can run
|
Thank you very much. I can see some messages when I used your file, and there are some indentation errors in mongo. However, the message displayed on the web page is 502 bad gateway. The log of sharelatex is as follows. nginx is not set in the file name. Why is nginx involved in the log? docker logs sharelatex 11:48:17
*** Running /etc/my_init.d/00_make_sharelatex_data_dirs.sh...
*** Running /etc/my_init.d/00_regen_sharelatex_secrets.sh...
generating random secrets
*** Running /etc/my_init.d/00_regen_ssh_host_keys.sh...
*** Running /etc/my_init.d/00_restore_site_status...
*** Running /etc/my_init.d/00_set_docker_host_ipaddress.sh...
*** Running /etc/my_init.d/01_nginx_config_template.sh...
Nginx: generating config file from template
Nginx: reloading config
* Reloading nginx configuration nginx
...done.
*** Running /etc/my_init.d/10_delete_old_logs.sh...
*** Running /etc/my_init.d/10_syslog-ng.init...
Apr 8 03:45:46 0ed0dc228956 syslog-ng[89]: syslog-ng starting up; version='3.25.1'
*** Running /etc/my_init.d/98_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/sharelatex/settings.js
Set UV_THREADPOOL_SIZE=16
Mongodb is up.
Using default settings from /overleaf/services/web/config/settings.defaults.js
Using settings from /etc/sharelatex/settings.js
Set UV_THREADPOOL_SIZE=16
Redis is up.
All checks passed
*** Running /etc/my_init.d/99_run_web_migrations.sh...
Running migrations for server-ce
> migrations
> MONGO_SOCKET_TIMEOUT=0 east migrate -t server-ce
Using default settings from /overleaf/services/web/config/settings.defaults.js
Using settings from /etc/sharelatex/settings.js
Set UV_THREADPOOL_SIZE=16
Nothing to migrate
Finished migrations
*** Booting runit daemon...
*** Runit started as PID 144
Apr 8 03:45:49 0ed0dc228956 cron[167]: (CRON) INFO (pidfile fd = 3)
Apr 8 03:45:49 0ed0dc228956 cron[167]: (CRON) INFO (Running @reboot jobs)
Apr 8 04:00:01 0ed0dc228956 CRON[317]: (root) CMD ( /overleaf/cron/project-history-periodic-flush.sh >> /var/log/sharelatex/cron-project-history-periodic-flush.log 2>&1) And this is the docker-compose.yml version: '2.2'
services:
sharelatex:
restart: always
# Server Pro users:
# image: quay.io/sharelatex/sharelatex-pro
image: sharelatex/sharelatex
container_name: sharelatex
depends_on:
mongo:
condition: service_healthy
redis:
condition: service_started
ports:
- 80:80
links:
- mongo
- redis
stop_grace_period: 60s
volumes:
- ~/sharelatex_data:/var/lib/overleaf
########################################################################
#### Server Pro: Uncomment the following line to mount the docker ####
#### socket, required for Sibling Containers to work ####
########################################################################
# - /var/run/docker.sock:/var/run/docker.sock
environment:
OVERLEAF_APP_NAME: Overleaf Community Edition
OVERLEAF_MONGO_URL: mongodb://mongo/sharelatex
SHARELATEX_MONGO_URL: mongodb://mongo/sharelatex
# Same property, unfortunately with different names in
# different locations
OVERLEAF_REDIS_HOST: redis
SHARELATEX_REDIS_HOST: redis
REDIS_HOST: redis
ENABLED_LINKED_FILE_TYPES: 'project_file,project_output_file'
# Enables Thumbnail generation using ImageMagick
ENABLE_CONVERSIONS: 'true'
# Disables email confirmation requirement
EMAIL_CONFIRMATION_DISABLED: 'true'
# temporary fix for LuaLaTex compiles
# see https://github.com/overleaf/overleaf/issues/695
TEXMFVAR: /var/lib/overleaf/tmp/texmf-var
## Set for SSL via nginx-proxy
#VIRTUAL_HOST: 103.112.212.22
# OVERLEAF_SITE_URL: http://overleaf.example.com
# OVERLEAF_NAV_TITLE: Overleaf Community Edition
# OVERLEAF_HEADER_IMAGE_URL: http://example.com/mylogo.png
# OVERLEAF_ADMIN_EMAIL: support@it.com
# OVERLEAF_LEFT_FOOTER: '[{"text": "Another page I want to link to can be found <a href=\"here\">here</a>"} ]'
# OVERLEAF_RIGHT_FOOTER: '[{"text": "Hello I am on the Right"} ]'
# OVERLEAF_EMAIL_FROM_ADDRESS: "hello@example.com"
# OVERLEAF_EMAIL_AWS_SES_ACCESS_KEY_ID:
# OVERLEAF_EMAIL_AWS_SES_SECRET_KEY:
# OVERLEAF_EMAIL_SMTP_HOST: smtp.example.com
# OVERLEAF_EMAIL_SMTP_PORT: 587
# OVERLEAF_EMAIL_SMTP_SECURE: false
# OVERLEAF_EMAIL_SMTP_USER:
# OVERLEAF_EMAIL_SMTP_PASS:
# OVERLEAF_EMAIL_SMTP_TLS_REJECT_UNAUTH: true
# OVERLEAF_EMAIL_SMTP_IGNORE_TLS: false
# OVERLEAF_EMAIL_SMTP_NAME: '127.0.0.1'
# OVERLEAF_EMAIL_SMTP_LOGGER: true
# OVERLEAF_CUSTOM_EMAIL_FOOTER: "This system is run by department x"
# ENABLE_CRON_RESOURCE_DELETION: true
################
## Server Pro ##
################
# SANDBOXED_COMPILES: 'true'
# SANDBOXED_COMPILES_SIBLING_CONTAINERS: 'true'
# SANDBOXED_COMPILES_HOST_DIR: '/var/sharelatex_data/data/compiles'
# DOCKER_RUNNER: 'false'
## Works with test LDAP server shown at bottom of docker compose
# OVERLEAF_LDAP_URL: 'ldap://ldap:389'
# OVERLEAF_LDAP_SEARCH_BASE: 'ou=people,dc=planetexpress,dc=com'
# OVERLEAF_LDAP_SEARCH_FILTER: '(uid={{username}})'
# OVERLEAF_LDAP_BIND_DN: 'cn=admin,dc=planetexpress,dc=com'
# OVERLEAF_LDAP_BIND_CREDENTIALS: 'GoodNewsEveryone'
# OVERLEAF_LDAP_EMAIL_ATT: 'mail'
# OVERLEAF_LDAP_NAME_ATT: 'cn'
# OVERLEAF_LDAP_LAST_NAME_ATT: 'sn'
# OVERLEAF_LDAP_UPDATE_USER_DETAILS_ON_LOGIN: 'true'
# OVERLEAF_TEMPLATES_USER_ID: "578773160210479700917ee5"
# OVERLEAF_NEW_PROJECT_TEMPLATE_LINKS: '[ {"name":"All Templates","url":"/templates/all"}]'
# OVERLEAF_PROXY_LEARN: "true"`
mongo:
restart: always
image: mongo:5.0
container_name: mongo
command: "--replSet overleaf"
expose:
- 27017
volumes:
- ~/mongo_data:/data/db
healthcheck:
test: echo 'db.stats().ok' | mongo localhost:27017/test --quiet
interval: 10s
timeout: 10s
retries: 5
mongoinit:
restart: "no"
image: mongo:5.0
depends_on:
mongo:
condition: service_healthy
entrypoint:
[
"mongo",
"--host",
"mongo:27017",
"--eval",
'rs.initiate({ _id: "overleaf", members: [ { _id: 0, host: "mongo:27017" } ] })',
]
redis:
restart: always
image: redis:6.2
container_name: redis
expose:
- 6379
volumes:
- ~/redis_data:/data
# ldap:
# restart: always
# image: rroemhild/test-openldap
# container_name: ldap
# expose:
# - 389
# See https://github.com/jwilder/nginx-proxy for documentation on how to configure the nginx-proxy container,
# and https://github.com/overleaf/overleaf/wiki/HTTPS-reverse-proxy-using-Nginx for an example of some recommended
# settings. We recommend using a properly managed nginx instance outside of the Overleaf Server Pro setup,
# but the example here can be used if you'd prefer to run everything with docker-compose
# nginx-proxy:
# image: jwilder/nginx-proxy
# container_name: nginx-proxy
# ports:
# #- "80:80"
# - "443:443"
# volumes:
# - /var/run/docker.sock:/tmp/docker.sock:ro
# - /home/overleaf/tmp:/etc/nginx/certs
|
Hello Everyone! I think i have found the reason and solution for this when working with docker swarm mode. Below.. I am using overleaf deployed to docker swarm. I used docker-compose.yml as a template for a docker swam stack file. After overleaf team switched mongo to replSet we faced a same problem when mongo can not connect to itself and initialize primary node. As a first fix of this problem i used manual commands in running mongo container:
After i tried to found the root cause. And it is that - once you start overleaf using docker swam mode, it appears a kind of race condition when mongod starts it tries to resolve The approach which give stable result is to use record in /etc/hosts file of the container for host mongo pointing to 127.0.0.1. As it goes that when mongod starts only /etc/hosts files resolving is working. So in this case adding: extra_hosts:
- "mongo:127.0.0.1" to compose/stack file works. So my solution is to use mongo service definition in docker swarm stack file like this: mongo:
image: mongo:4.4
command: "--replSet overleaf"
logging:
driver: "json-file"
options:
max-size: "100m"
max-file: "3"
volumes:
- /srv/overleaf/mongo:/data/db
networks:
- overleaf
extra_hosts:
- "mongo:127.0.0.1"
healthcheck:
test: echo 'db.stats().ok' | mongo localhost:27017/test --quiet
interval: 10s
timeout: 10s
retries: 5
deploy:
mode: replicated
replicas: 1
placement:
constraints:
- node.labels.overleaf_server == true |
is there a working solution ? |
I just worked through this actually and nothing helped until I did the following. Have you by chance changed the name of your Basically, I had to change the replica set member[0] to refer to the new container name. I did this by logging into the After this change, the new |
Steps to Reproduce
I am attempting to run overleaf from a Portainer stack, as I prefer to manage all my services this way.
When I ran into issues, I attempted to used the default docker compose provided on the github, but that is still giving me the same issue.
Expected Behaviour
Sharelatex should start up and be able to connect to mongodb.
Observed Behaviour
Sharelatex fails to connect to mongo db and therefore won't start.
I keep getting this in the logs:
Context
I suspect user error. I have been beating my head against this for a couple days now.
I have tried my docker compose.
I have also tried an unedited version of the provided compose file (this one). Same issue.
I have tried adding a new docker network for all three services to share, to see if that would fix the communication issue.
Technical Info
Server is running Ubuntu 22.04.3 with Docker and Portainer installed.
Analysis
The text was updated successfully, but these errors were encountered: