Ubuntu Rocket.Chat Docker server migration is stuck on connecting to it's MongoDB container


We’re a cultural non-profit community project running a Rocket.Chat Instance over several years now already. It’s the foundation of all our communications and we’re very thankful to have such an open source tool at our fingertips. Unfortunately we had to move servers because of an issues with our old hoster. Everything went fine except Rocket.Chat, which we are really struggling with getting it back up running.

Both systems are almost identical and meet all the requirements. The main difference is the upgrade in the OS, which was a Ubuntu 20.04.6 LTS and now is a Ubuntu 22.04.4 LTS. Both servers are running Plesk Obsidian v18.0.58 with Docker environment having Rocket.Chat and MongoDB each in one container.

As far as I understand the problem the Rocket.Chat instance can’t connect to the MongoDB, since it always shuts down again after start.

The docker container is throwing errors like this:

  • MongoServerSelectionError: getaddrinfo EAI_AGAIN mongo at Timeout._onTimeout (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/sdam/topology.js:292:38)
  • MongoNetworkError: getaddrinfo EAI_AGAIN mongo at connectionFailureError (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/cmap/connect.js:387:20)

The webspace logs in Plesk give me this repetitive upstream error:

  • 105237#0: *63806 recv() failed (104: Connection reset by peer) while reading response header from upstream

Server Setup Information

  • Version of Rocket.Chat Server: 6.4.2
  • Operating System: Ubuntu 22.04.4 LTS
  • Deployment Method: docker
  • Number of Running Instances: 1
  • DB Replicaset Oplog: mongod --oplogSize 128 --replSet rs0 --storageEngine=wiredTiger
  • NodeJS Version: 14.21.3
  • MongoDB Version: 6.0.13
  • Proxy: nginx
  • Firewalls involved: yes, but tested without

Any additional Information

This is how the docker-compose.yml looks like:

    #image: rocketchat/rocket.chat:latest
    image: rocketchat/rocket.chat:6.4.2
    restart: unless-stopped
    command: >
      bash -c
        "for (( ; ; )); do
          node main.js &&
          s=$$? && break || s=$$?;
          echo \"Could not start Rocket.Chat. Waiting 5 secs...\";
          sleep 5;
        done; (exit $$s)"
      - ./data/uploads:/app/uploads
      - PORT=3000
      - ROOT_URL=https://chat.laissez-faire.org
      #- MONGO_URL=mongodb://mongo:27017/rocketchat
      - MONGO_URL=mongodb://mongo:27017/rocketchat?replicaSet=rs0&directConnection=true
      - MONGO_OPLOG_URL=mongodb://mongo:27017/local
      - Accounts_UseDNSDomainCheck=false
      - LETSENCRYPT_HOST=chat.laissez-faire.org
      - VIRTUAL_HOST=chat.laissez-faire.org
      #- MAIL_URL=smtp://smtp.email
      #- MAIL_URL=smtp://laissez-faire.org:465
      #- HTTP_PROXY=http://proxy.domain.com
      #- HTTPS_PROXY=http://proxy.domain.com
      - mongo
      - 3000:3000
    user: 10010:1003
      #- "traefik.backend=rocketchat"
      #- "traefik.frontend.rule=Host: chat.laissez-faire.org"
      - "traefik.enable=false"

    container_name: mongo
    image: mongo:6.0
    restart: unless-stopped
     - ./data/db:/data/db
     - ./data/configdb:/data/configdb
     - ./data/dump:/dump
    #command: mongod --smallfiles --oplogSize 128 --replSet rs0 --storageEngine=wiredTiger
    command: mongod --oplogSize 128 --replSet rs0 --storageEngine=wiredTiger
      - "traefik.enable=false"
    user: 10010:1003

#    environment:

These are my additional nginx directives:

location ~ ^/.* {
	proxy_set_header Host $host;
	proxy_set_header X-Real-IP $remote_addr;
	proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
	proxy_set_header Upgrade $http_upgrade;
	proxy_set_header Connection "upgrade";
	proxy_set_header X-Forwarded-Proto http;
	proxy_set_header X-Nginx-Proxy true;
	proxy_http_version 1.1;
	proxy_redirect off;

Here are my installation logs for Docker ( [brackets] are inserted for link protection, new users are only allowed to post two links):

sudo apt update
sudo apt install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://[download.docker].com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://[download.docker].com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update
apt-cache policy docker-ce
sudo apt install docker-ce
sudo systemctl status docker -> check!

Docker Compose was installed like this:

mkdir -p ~/.docker/cli-plugins/
curl -SL https://[github].com/docker/compose/releases/download/v2.26.0/docker-compose-linux-x86_64 -o ~/.docker/cli-plugins/docker-compose
chmod +x ~/.docker/cli-plugins/docker-compose
docker compose version -> check!

NodeJS was installed via Plesk:

cd /root
curl -o- https://[raw.githubusercontent].com/nvm-sh/nvm/v0.39.7/install.sh | bash
wget -qO- https://[raw.githubusercontent].com/nvm-sh/nvm/v0.38.0/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
cp -R /root/.nvm/versions/node/v14.21.3 /opt/plesk/node/
plesk sbin nodemng register /opt/plesk/node/14.21.3/bin/node

I really don’t even know anymore where or what to check. Maybe there is somewhere some sort of incompatibility, but as far as I checked all the versions they should run together. For me it seems that something with the MongoDB container is wrong, but what?

Thanks everybody to contributing to helping us fixing this problem and giving us back our Rocket.Chat baby you great human beings! <3