overleaf / overleaf

A web-based collaborative LaTeX editor

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot connect to mongodb (user error?)

KK4BitsPerSecond opened this issue · comments

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:

Using settings from /etc/sharelatex/settings.js
Set UV_THREADPOOL_SIZE=16
Cannot connect to mongodb
MongooseServerSelectionError: Server selection timed out after 60000 ms
    at Connection.openUri (/overleaf/services/web/node_modules/mongoose/lib/connection.js:825:32)
    at /overleaf/services/web/node_modules/mongoose/lib/index.js:414:10
    at /overleaf/services/web/node_modules/mongoose/lib/helpers/promiseOrCallback.js:41:5
    at new Promise (<anonymous>)
    at promiseOrCallback (/overleaf/services/web/node_modules/mongoose/lib/helpers/promiseOrCallback.js:40:10)
    at Mongoose._promiseOrCallback (/overleaf/services/web/node_modules/mongoose/lib/index.js:1288:10)
    at Mongoose.connect (/overleaf/services/web/node_modules/mongoose/lib/index.js:413:20)
    at Object.<anonymous> (/overleaf/services/web/app/src/infrastructure/Mongoose.js:19:36)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10) {
  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
}
*** /etc/my_init.d/98_check_db_access.sh failed with status 1
*** Killing all processes...

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

And what do mongodb logs say?

And what do mongodb logs say?

That would be helpful. Sorry.

Mongo Container Logs:

2024-02-12T15:45:41.309+0000 I NETWORK  [conn5122] received client metadata from 127.0.0.1:35158 conn5122: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:45:41.315+0000 I NETWORK  [conn5122] end connection 127.0.0.1:35158 (1 connection now open)
2024-02-12T15:45:51.445+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:50152 #5123 (2 connections now open)
2024-02-12T15:45:51.465+0000 I NETWORK  [conn5123] received client metadata from 127.0.0.1:50152 conn5123: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:45:51.470+0000 I NETWORK  [conn5123] end connection 127.0.0.1:50152 (1 connection now open)
2024-02-12T15:46:01.611+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:45550 #5124 (2 connections now open)
2024-02-12T15:46:01.629+0000 I NETWORK  [conn5124] received client metadata from 127.0.0.1:45550 conn5124: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:46:01.635+0000 I NETWORK  [conn5124] end connection 127.0.0.1:45550 (1 connection now open)
2024-02-12T15:46:11.780+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:47344 #5125 (2 connections now open)
2024-02-12T15:46:11.801+0000 I NETWORK  [conn5125] received client metadata from 127.0.0.1:47344 conn5125: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:46:11.807+0000 I NETWORK  [conn5125] end connection 127.0.0.1:47344 (1 connection now open)
2024-02-12T15:46:21.962+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:43536 #5126 (2 connections now open)
2024-02-12T15:46:21.982+0000 I NETWORK  [conn5126] received client metadata from 127.0.0.1:43536 conn5126: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:46:21.987+0000 I NETWORK  [conn5126] end connection 127.0.0.1:43536 (1 connection now open)
2024-02-12T15:46:31.819+0000 I NETWORK  [conn5121] end connection 192.168.128.4:44718 (0 connections now open)
2024-02-12T15:46:32.102+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:36952 #5127 (1 connection now open)
2024-02-12T15:46:32.103+0000 I NETWORK  [conn5127] received client metadata from 127.0.0.1:36952 conn5127: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:46:32.111+0000 I NETWORK  [conn5127] end connection 127.0.0.1:36952 (0 connections now open)
2024-02-12T15:46:34.351+0000 I NETWORK  [listener] connection accepted from 192.168.128.4:42078 #5128 (1 connection now open)
2024-02-12T15:46:34.360+0000 I NETWORK  [conn5128] received client metadata from 192.168.128.4:42078 conn5128: { application: { name: "web" }, driver: { name: "nodejs|Mongoose", version: "4.17.1|6.12.0" }, platform: "Node.js v18.18.2, LE", os: { name: "linux", architecture: "x64", version: "5.15.0-94-generic", type: "Linux" } }
2024-02-12T15:46:42.249+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:34992 #5129 (2 connections now open)
2024-02-12T15:46:42.271+0000 I NETWORK  [conn5129] received client metadata from 127.0.0.1:34992 conn5129: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:46:42.287+0000 I NETWORK  [conn5129] end connection 127.0.0.1:34992 (1 connection now open)
2024-02-12T15:46:52.428+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:48314 #5130 (2 connections now open)
2024-02-12T15:46:52.447+0000 I NETWORK  [conn5130] received client metadata from 127.0.0.1:48314 conn5130: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:46:52.463+0000 I NETWORK  [conn5130] end connection 127.0.0.1:48314 (1 connection now open)
2024-02-12T15:47:02.597+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:49976 #5131 (2 connections now open)
2024-02-12T15:47:02.617+0000 I NETWORK  [conn5131] received client metadata from 127.0.0.1:49976 conn5131: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:47:02.623+0000 I NETWORK  [conn5131] end connection 127.0.0.1:49976 (1 connection now open)
2024-02-12T15:47:12.760+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:60100 #5132 (2 connections now open)
2024-02-12T15:47:12.777+0000 I NETWORK  [conn5132] received client metadata from 127.0.0.1:60100 conn5132: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:47:12.782+0000 I NETWORK  [conn5132] end connection 127.0.0.1:60100 (1 connection now open)
2024-02-12T15:47:22.911+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:36824 #5133 (2 connections now open)
2024-02-12T15:47:22.930+0000 I NETWORK  [conn5133] received client metadata from 127.0.0.1:36824 conn5133: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:47:22.941+0000 I NETWORK  [conn5133] end connection 127.0.0.1:36824 (1 connection now open)
2024-02-12T15:47:33.091+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:50850 #5134 (2 connections now open)
2024-02-12T15:47:33.110+0000 I NETWORK  [conn5134] received client metadata from 127.0.0.1:50850 conn5134: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:47:33.115+0000 I NETWORK  [conn5134] end connection 127.0.0.1:50850 (1 connection now open)
2024-02-12T15:47:34.354+0000 I NETWORK  [conn5128] end connection 192.168.128.4:42078 (0 connections now open)
2024-02-12T15:47:36.986+0000 I NETWORK  [listener] connection accepted from 192.168.128.4:58914 #5135 (1 connection now open)
2024-02-12T15:47:36.993+0000 I NETWORK  [conn5135] received client metadata from 192.168.128.4:58914 conn5135: { application: { name: "web" }, driver: { name: "nodejs|Mongoose", version: "4.17.1|6.12.0" }, platform: "Node.js v18.18.2, LE", os: { name: "linux", architecture: "x64", version: "5.15.0-94-generic", type: "Linux" } }
2024-02-12T15:47:43.262+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:53064 #5136 (2 connections now open)
2024-02-12T15:47:43.263+0000 I NETWORK  [conn5136] received client metadata from 127.0.0.1:53064 conn5136: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:47:43.268+0000 I NETWORK  [conn5136] end connection 127.0.0.1:53064 (1 connection now open)
2024-02-12T15:47:53.397+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:43932 #5137 (2 connections now open)
2024-02-12T15:47:53.417+0000 I NETWORK  [conn5137] received client metadata from 127.0.0.1:43932 conn5137: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:47:53.423+0000 I NETWORK  [conn5137] end connection 127.0.0.1:43932 (1 connection now open)
2024-02-12T15:48:03.565+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:54276 #5138 (2 connections now open)
2024-02-12T15:48:03.585+0000 I NETWORK  [conn5138] received client metadata from 127.0.0.1:54276 conn5138: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:48:03.591+0000 I NETWORK  [conn5138] end connection 127.0.0.1:54276 (1 connection now open)
2024-02-12T15:48:13.723+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:56930 #5139 (2 connections now open)
2024-02-12T15:48:13.741+0000 I NETWORK  [conn5139] received client metadata from 127.0.0.1:56930 conn5139: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:48:13.746+0000 I NETWORK  [conn5139] end connection 127.0.0.1:56930 (1 connection now open)
2024-02-12T15:48:23.874+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:42930 #5140 (2 connections now open)
2024-02-12T15:48:23.893+0000 I NETWORK  [conn5140] received client metadata from 127.0.0.1:42930 conn5140: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:48:23.899+0000 I NETWORK  [conn5140] end connection 127.0.0.1:42930 (1 connection now open)
2024-02-12T15:48:34.052+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:40206 #5141 (2 connections now open)
2024-02-12T15:48:34.075+0000 I NETWORK  [conn5141] received client metadata from 127.0.0.1:40206 conn5141: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:48:34.090+0000 I NETWORK  [conn5141] end connection 127.0.0.1:40206 (1 connection now open)
2024-02-12T15:48:36.989+0000 I NETWORK  [conn5135] end connection 192.168.128.4:58914 (0 connections now open)
2024-02-12T15:48:39.710+0000 I NETWORK  [listener] connection accepted from 192.168.128.4:56014 #5142 (1 connection now open)
2024-02-12T15:48:39.716+0000 I NETWORK  [conn5142] received client metadata from 192.168.128.4:56014 conn5142: { application: { name: "web" }, driver: { name: "nodejs|Mongoose", version: "4.17.1|6.12.0" }, platform: "Node.js v18.18.2, LE", os: { name: "linux", architecture: "x64", version: "5.15.0-94-generic", type: "Linux" } }
2024-02-12T15:48:44.227+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:43020 #5143 (2 connections now open)
2024-02-12T15:48:44.245+0000 I NETWORK  [conn5143] received client metadata from 127.0.0.1:43020 conn5143: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:48:44.251+0000 I NETWORK  [conn5143] end connection 127.0.0.1:43020 (1 connection now open)
2024-02-12T15:48:54.386+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:36766 #5144 (2 connections now open)
2024-02-12T15:48:54.405+0000 I NETWORK  [conn5144] received client metadata from 127.0.0.1:36766 conn5144: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:48:54.411+0000 I NETWORK  [conn5144] end connection 127.0.0.1:36766 (1 connection now open)
2024-02-12T15:49:04.548+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:42776 #5145 (2 connections now open)
2024-02-12T15:49:04.565+0000 I NETWORK  [conn5145] received client metadata from 127.0.0.1:42776 conn5145: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:49:04.570+0000 I NETWORK  [conn5145] end connection 127.0.0.1:42776 (1 connection now open)
2024-02-12T15:49:09.044+0000 I CONTROL  [LogicalSessionCacheRefresh] Sessions collection is not set up; waiting until next sessions refresh interval: Replication has not yet been configured
2024-02-12T15:49:09.045+0000 I CONTROL  [LogicalSessionCacheReap] Sessions collection is not set up; waiting until next sessions reap interval: config.system.sessions does not exist
2024-02-12T15:49:14.742+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:53200 #5146 (2 connections now open)
2024-02-12T15:49:14.761+0000 I NETWORK  [conn5146] received client metadata from 127.0.0.1:53200 conn5146: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:49:14.767+0000 I NETWORK  [conn5146] end connection 127.0.0.1:53200 (1 connection now open)
2024-02-12T15:49:24.909+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:43054 #5147 (2 connections now open)
2024-02-12T15:49:24.930+0000 I NETWORK  [conn5147] received client metadata from 127.0.0.1:43054 conn5147: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:49:24.935+0000 I NETWORK  [conn5147] end connection 127.0.0.1:43054 (1 connection now open)
2024-02-12T15:49:35.075+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:59968 #5148 (2 connections now open)
2024-02-12T15:49:35.093+0000 I NETWORK  [conn5148] received client metadata from 127.0.0.1:59968 conn5148: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:49:35.099+0000 I NETWORK  [conn5148] end connection 127.0.0.1:59968 (1 connection now open)
2024-02-12T15:49:39.711+0000 I NETWORK  [conn5142] end connection 192.168.128.4:56014 (0 connections now open)
2024-02-12T15:49:42.365+0000 I NETWORK  [listener] connection accepted from 192.168.128.4:44096 #5149 (1 connection now open)
2024-02-12T15:49:42.373+0000 I NETWORK  [conn5149] received client metadata from 192.168.128.4:44096 conn5149: { application: { name: "web" }, driver: { name: "nodejs|Mongoose", version: "4.17.1|6.12.0" }, platform: "Node.js v18.18.2, LE", os: { name: "linux", architecture: "x64", version: "5.15.0-94-generic", type: "Linux" } }
2024-02-12T15:49:45.237+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:41838 #5150 (2 connections now open)
2024-02-12T15:49:45.259+0000 I NETWORK  [conn5150] received client metadata from 127.0.0.1:41838 conn5150: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:49:45.274+0000 I NETWORK  [conn5150] end connection 127.0.0.1:41838 (1 connection now open)
2024-02-12T15:49:55.430+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:48996 #5151 (2 connections now open)
2024-02-12T15:49:55.450+0000 I NETWORK  [conn5151] received client metadata from 127.0.0.1:48996 conn5151: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:49:55.455+0000 I NETWORK  [conn5151] end connection 127.0.0.1:48996 (1 connection now open)
2024-02-12T15:50:05.595+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:44462 #5152 (2 connections now open)
2024-02-12T15:50:05.614+0000 I NETWORK  [conn5152] received client metadata from 127.0.0.1:44462 conn5152: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:50:05.619+0000 I NETWORK  [conn5152] end connection 127.0.0.1:44462 (1 connection now open)
2024-02-12T15:50:15.786+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:43576 #5153 (2 connections now open)
2024-02-12T15:50:15.805+0000 I NETWORK  [conn5153] received client metadata from 127.0.0.1:43576 conn5153: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:50:15.810+0000 I NETWORK  [conn5153] end connection 127.0.0.1:43576 (1 connection now open)
2024-02-12T15:50:25.960+0000 I NETWORK  [listener] connection accepted from 127.0.0.1:51694 #5154 (2 connections now open)
2024-02-12T15:50:25.979+0000 I NETWORK  [conn5154] received client metadata from 127.0.0.1:51694 conn5154: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.28" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
2024-02-12T15:50:25.995+0000 I NETWORK  [conn5154] end connection 127.0.0.1:51694 (1 connection now open)

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 SHARELATEX_XXX now is OVERLEAF_XXX, you can check if your OVERLEAF_MONGO_URL is set correctly

commented

Can confirm the issue. The provided docker-compose.yml does not work.

# download compose example
wget https://raw.githubusercontent.com/overleaf/overleaf/main/docker-compose.yml

# spawn the stack
docker compose up

Results in:

sharelatex  | Cannot connect to mongodb
sharelatex  | MongooseServerSelectionError: connect ECONNREFUSED 172.27.0.1:27017
sharelatex  |     at Connection.openUri (/overleaf/services/web/node_modules/mongoose/lib/connection.js:825:32)
sharelatex  |     at /overleaf/services/web/node_modules/mongoose/lib/index.js:414:10
sharelatex  |     at /overleaf/services/web/node_modules/mongoose/lib/helpers/promiseOrCallback.js:41:5
sharelatex  |     at new Promise (<anonymous>)
sharelatex  |     at promiseOrCallback (/overleaf/services/web/node_modules/mongoose/lib/helpers/promiseOrCallback.js:40:10)
sharelatex  |     at Mongoose._promiseOrCallback (/overleaf/services/web/node_modules/mongoose/lib/index.js:1288:10)
sharelatex  |     at Mongoose.connect (/overleaf/services/web/node_modules/mongoose/lib/index.js:413:20)
sharelatex  |     at Object.<anonymous> (/overleaf/services/web/app/src/infrastructure/Mongoose.js:19:36)
sharelatex  |     at Module._compile (node:internal/modules/cjs/loader:1256:14)
sharelatex  |     at Module._extensions..js (node:internal/modules/cjs/loader:1310:10) {
sharelatex  |   reason: TopologyDescription {
sharelatex  |     type: 'Unknown',
sharelatex  |     servers: Map(1) { 'dockerhost:27017' => [ServerDescription] },
sharelatex  |     stale: false,
sharelatex  |     compatible: true,
sharelatex  |     heartbeatFrequencyMS: 10000,
sharelatex  |     localThresholdMS: 15,
sharelatex  |     setName: null,
sharelatex  |     maxElectionId: null,
sharelatex  |     maxSetVersion: null,
sharelatex  |     commonWireVersion: 0,
sharelatex  |     logicalSessionTimeoutMinutes: null
sharelatex  |   },
sharelatex  |   code: undefined
sharelatex  | }
sharelatex  | *** /etc/my_init.d/98_check_db_access.sh failed with status 1
sharelatex  | 
sharelatex  | *** Killing all processes...
sharelatex  | Feb 15 11:26:04 3ecccede0577 syslog-ng[89]: syslog-ng shutting down; version='3.25.1'
sharelatex exited with code 0
sharelatex  | *** Running /etc/my_init.d/00_make_sharelatex_data_dirs.sh...                                                                                          
sharelatex  | *** Running /etc/my_init.d/00_regen_sharelatex_secrets.sh...
sharelatex  | *** Running /etc/my_init.d/00_regen_ssh_host_keys.sh...
sharelatex  | *** Running /etc/my_init.d/00_restore_site_status...
sharelatex  | *** Running /etc/my_init.d/00_set_docker_host_ipaddress.sh...
sharelatex  | *** Running /etc/my_init.d/01_nginx_config_template.sh...
sharelatex  | Nginx: generating config file from template
sharelatex  | Nginx: reloading config
sharelatex  |  * Reloading nginx configuration nginx
sharelatex  |    ...done.
sharelatex  | *** Running /etc/my_init.d/10_delete_old_logs.sh...
sharelatex  | *** Running /etc/my_init.d/10_syslog-ng.init...
sharelatex  | Feb 15 11:26:04 3ecccede0577 syslog-ng[60]: syslog-ng starting up; version='3.25.1'
sharelatex  | *** Running /etc/my_init.d/98_check_db_access.sh...
sharelatex  | Checking can connect to mongo and redis
sharelatex  | Using default settings from /overleaf/services/web/config/settings.defaults.js
sharelatex  | Using settings from /etc/sharelatex/settings.js
sharelatex  | Set UV_THREADPOOL_SIZE=16
^CGracefully stopping... (press Ctrl+C again to force)
````

Can confirm the issue. The provided docker-compose.yml does not work.

# download compose example
wget https://raw.githubusercontent.com/overleaf/overleaf/main/docker-compose.yml

# spawn the stack
docker compose up

Results in:

sharelatex  | Cannot connect to mongodb
sharelatex  | MongooseServerSelectionError: connect ECONNREFUSED 172.27.0.1:27017
sharelatex  |     at Connection.openUri (/overleaf/services/web/node_modules/mongoose/lib/connection.js:825:32)
sharelatex  |     at /overleaf/services/web/node_modules/mongoose/lib/index.js:414:10
sharelatex  |     at /overleaf/services/web/node_modules/mongoose/lib/helpers/promiseOrCallback.js:41:5
sharelatex  |     at new Promise (<anonymous>)
sharelatex  |     at promiseOrCallback (/overleaf/services/web/node_modules/mongoose/lib/helpers/promiseOrCallback.js:40:10)
sharelatex  |     at Mongoose._promiseOrCallback (/overleaf/services/web/node_modules/mongoose/lib/index.js:1288:10)
sharelatex  |     at Mongoose.connect (/overleaf/services/web/node_modules/mongoose/lib/index.js:413:20)
sharelatex  |     at Object.<anonymous> (/overleaf/services/web/app/src/infrastructure/Mongoose.js:19:36)
sharelatex  |     at Module._compile (node:internal/modules/cjs/loader:1256:14)
sharelatex  |     at Module._extensions..js (node:internal/modules/cjs/loader:1310:10) {
sharelatex  |   reason: TopologyDescription {
sharelatex  |     type: 'Unknown',
sharelatex  |     servers: Map(1) { 'dockerhost:27017' => [ServerDescription] },
sharelatex  |     stale: false,
sharelatex  |     compatible: true,
sharelatex  |     heartbeatFrequencyMS: 10000,
sharelatex  |     localThresholdMS: 15,
sharelatex  |     setName: null,
sharelatex  |     maxElectionId: null,
sharelatex  |     maxSetVersion: null,
sharelatex  |     commonWireVersion: 0,
sharelatex  |     logicalSessionTimeoutMinutes: null
sharelatex  |   },
sharelatex  |   code: undefined
sharelatex  | }
sharelatex  | *** /etc/my_init.d/98_check_db_access.sh failed with status 1
sharelatex  | 
sharelatex  | *** Killing all processes...
sharelatex  | Feb 15 11:26:04 3ecccede0577 syslog-ng[89]: syslog-ng shutting down; version='3.25.1'
sharelatex exited with code 0
sharelatex  | *** Running /etc/my_init.d/00_make_sharelatex_data_dirs.sh...                                                                                          
sharelatex  | *** Running /etc/my_init.d/00_regen_sharelatex_secrets.sh...
sharelatex  | *** Running /etc/my_init.d/00_regen_ssh_host_keys.sh...
sharelatex  | *** Running /etc/my_init.d/00_restore_site_status...
sharelatex  | *** Running /etc/my_init.d/00_set_docker_host_ipaddress.sh...
sharelatex  | *** Running /etc/my_init.d/01_nginx_config_template.sh...
sharelatex  | Nginx: generating config file from template
sharelatex  | Nginx: reloading config
sharelatex  |  * Reloading nginx configuration nginx
sharelatex  |    ...done.
sharelatex  | *** Running /etc/my_init.d/10_delete_old_logs.sh...
sharelatex  | *** Running /etc/my_init.d/10_syslog-ng.init...
sharelatex  | Feb 15 11:26:04 3ecccede0577 syslog-ng[60]: syslog-ng starting up; version='3.25.1'
sharelatex  | *** Running /etc/my_init.d/98_check_db_access.sh...
sharelatex  | Checking can connect to mongo and redis
sharelatex  | Using default settings from /overleaf/services/web/config/settings.defaults.js
sharelatex  | Using settings from /etc/sharelatex/settings.js
sharelatex  | Set UV_THREADPOOL_SIZE=16
^CGracefully stopping... (press Ctrl+C again to force)

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:

# docker-compose 启动mongo服务
docker-compose up -d mongo

docker-compose exec -T mongo sh -c '
    while ! mongo --eval "db.version()" > /dev/null; do
      echo "Waiting for Mongo..."
      sleep 1
    done
    mongo --eval "rs.initiate({ _id: \"overleaf\", members: [ { _id: 0, host: \"mongo:27017\" } ] })" > /dev/null'

commented

Can confirm the issue. The provided docker-compose.yml does not work.

# download compose example
wget https://raw.githubusercontent.com/overleaf/overleaf/main/docker-compose.yml

# spawn the stack
docker compose up

Results in:

sharelatex  | Cannot connect to mongodb
sharelatex  | MongooseServerSelectionError: connect ECONNREFUSED 172.27.0.1:27017
sharelatex  |     at Connection.openUri (/overleaf/services/web/node_modules/mongoose/lib/connection.js:825:32)
sharelatex  |     at /overleaf/services/web/node_modules/mongoose/lib/index.js:414:10
sharelatex  |     at /overleaf/services/web/node_modules/mongoose/lib/helpers/promiseOrCallback.js:41:5
sharelatex  |     at new Promise (<anonymous>)
sharelatex  |     at promiseOrCallback (/overleaf/services/web/node_modules/mongoose/lib/helpers/promiseOrCallback.js:40:10)
sharelatex  |     at Mongoose._promiseOrCallback (/overleaf/services/web/node_modules/mongoose/lib/index.js:1288:10)
sharelatex  |     at Mongoose.connect (/overleaf/services/web/node_modules/mongoose/lib/index.js:413:20)
sharelatex  |     at Object.<anonymous> (/overleaf/services/web/app/src/infrastructure/Mongoose.js:19:36)
sharelatex  |     at Module._compile (node:internal/modules/cjs/loader:1256:14)
sharelatex  |     at Module._extensions..js (node:internal/modules/cjs/loader:1310:10) {
sharelatex  |   reason: TopologyDescription {
sharelatex  |     type: 'Unknown',
sharelatex  |     servers: Map(1) { 'dockerhost:27017' => [ServerDescription] },
sharelatex  |     stale: false,
sharelatex  |     compatible: true,
sharelatex  |     heartbeatFrequencyMS: 10000,
sharelatex  |     localThresholdMS: 15,
sharelatex  |     setName: null,
sharelatex  |     maxElectionId: null,
sharelatex  |     maxSetVersion: null,
sharelatex  |     commonWireVersion: 0,
sharelatex  |     logicalSessionTimeoutMinutes: null
sharelatex  |   },
sharelatex  |   code: undefined
sharelatex  | }
sharelatex  | *** /etc/my_init.d/98_check_db_access.sh failed with status 1
sharelatex  | 
sharelatex  | *** Killing all processes...
sharelatex  | Feb 15 11:26:04 3ecccede0577 syslog-ng[89]: syslog-ng shutting down; version='3.25.1'
sharelatex exited with code 0
sharelatex  | *** Running /etc/my_init.d/00_make_sharelatex_data_dirs.sh...                                                                                          
sharelatex  | *** Running /etc/my_init.d/00_regen_sharelatex_secrets.sh...
sharelatex  | *** Running /etc/my_init.d/00_regen_ssh_host_keys.sh...
sharelatex  | *** Running /etc/my_init.d/00_restore_site_status...
sharelatex  | *** Running /etc/my_init.d/00_set_docker_host_ipaddress.sh...
sharelatex  | *** Running /etc/my_init.d/01_nginx_config_template.sh...
sharelatex  | Nginx: generating config file from template
sharelatex  | Nginx: reloading config
sharelatex  |  * Reloading nginx configuration nginx
sharelatex  |    ...done.
sharelatex  | *** Running /etc/my_init.d/10_delete_old_logs.sh...
sharelatex  | *** Running /etc/my_init.d/10_syslog-ng.init...
sharelatex  | Feb 15 11:26:04 3ecccede0577 syslog-ng[60]: syslog-ng starting up; version='3.25.1'
sharelatex  | *** Running /etc/my_init.d/98_check_db_access.sh...
sharelatex  | Checking can connect to mongo and redis
sharelatex  | Using default settings from /overleaf/services/web/config/settings.defaults.js
sharelatex  | Using settings from /etc/sharelatex/settings.js
sharelatex  | Set UV_THREADPOOL_SIZE=16
^CGracefully stopping... (press Ctrl+C again to force)

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:

# docker-compose 启动mongo服务
docker-compose up -d mongo

docker-compose exec -T mongo sh -c '
    while ! mongo --eval "db.version()" > /dev/null; do
      echo "Waiting for Mongo..."
      sleep 1
    done
    mongo --eval "rs.initiate({ _id: \"overleaf\", members: [ { _id: 0, host: \"mongo:27017\" } ] })" > /dev/null'

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.

https://raw.githubusercontent.com/overleaf/overleaf/main/docker-compose.yml

Oh, I got.

Currently, Overleaf is doing rebranding, which means all environment var starting with SHARELATEX_XXX is now OVERLEAF_XXX, including SHARELATEX_MONGO, now it is OVERLEAF_MONGO

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.

https://raw.githubusercontent.com/overleaf/overleaf/main/docker-compose.yml

Oh, I got.

Currently, Overleaf is doing rebranding, which means all environment var starting with SHARELATEX_XXX is now OVERLEAF_XXX, including SHARELATEX_MONGO, now it is OVERLEAF_MONGO

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:

  • in overleaf 5.0, data mount path may change from sharelatex to overleaf, you need to manually migrate your data folder.
  • in overleaf 5.0, all environment SHARELATEX_XXX will be OVERLEAF_MONGO
    I don't think you have so much patience for dealing with so much chores, with toolkit, you can make it easier to upgrade.

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 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 SHARELATEX_XXX now is OVERLEAF_XXX, you can check if your OVERLEAF_MONGO_URL is set correctly

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.

Why not use toolkit? http://github.com/overleaf/toolkit

Personally, because I already run all of my other containers through Portainer.

Use toolkit is a better solution, if you use direct docker-compose yml file, you need to run this first:

# docker-compose 启动mongo服务
docker-compose up -d mongo

docker-compose exec -T mongo sh -c '
    while ! mongo --eval "db.version()" > /dev/null; do
      echo "Waiting for Mongo..."
      sleep 1
    done
    mongo --eval "rs.initiate({ _id: \"overleaf\", members: [ { _id: 0, host: \"mongo:27017\" } ] })" > /dev/null'

Hopefully, I will have some time to try this tonight.

Use toolkit is a better solution, if you use direct docker-compose yml file, you need to run this first:

# docker-compose 启动mongo服务
docker-compose up -d mongo

docker-compose exec -T mongo sh -c '
    while ! mongo --eval "db.version()" > /dev/null; do
      echo "Waiting for Mongo..."
      sleep 1
    done
    mongo --eval "rs.initiate({ _id: \"overleaf\", members: [ { _id: 0, host: \"mongo:27017\" } ] })" > /dev/null'

These lines work well! Thanks a lot.

Use toolkit is a better solution, if you use direct docker-compose yml file, you need to run this first:

# docker-compose 启动mongo服务
docker-compose up -d mongo

docker-compose exec -T mongo sh -c '
    while ! mongo --eval "db.version()" > /dev/null; do
      echo "Waiting for Mongo..."
      sleep 1
    done
    mongo --eval "rs.initiate({ _id: \"overleaf\", members: [ { _id: 0, host: \"mongo:27017\" } ] })" > /dev/null'

These lines work well! Thanks a lot.
I tried this and it did not work for me. Will give it another try, probably next weekend.
There has to be something I'm doing wrong.

Use toolkit is a better solution, if you use direct docker-compose yml file, you need to run this first:

# docker-compose 启动mongo服务
docker-compose up -d mongo

docker-compose exec -T mongo sh -c '
    while ! mongo --eval "db.version()" > /dev/null; do
      echo "Waiting for Mongo..."
      sleep 1
    done
    mongo --eval "rs.initiate({ _id: \"overleaf\", members: [ { _id: 0, host: \"mongo:27017\" } ] })" > /dev/null'

These lines work well! Thanks a lot.

I have the same problem as above, doesn't work for me... Still getting the same error