# Docker Upgrade Issues

**URL:** https://forums.rocket.chat/t/docker-upgrade-issues/14804
**Category:** Community Support
**Created:** [August 30, 2022, 1:43pm UTC](https://forums.rocket.chat/t/docker-upgrade-issues/14804 "2022-08-30T13:43:56Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![creiss](https://sea1.discourse-cdn.com/flex021/user_avatar/forums.rocket.chat/creiss/32/3455_2.png) [@creiss](https://forums.rocket.chat/u/creiss)
#### Post date: [August 30, 2022, 1:43pm UTC](https://forums.rocket.chat/t/docker-upgrade-issues/14804/1 "2022-08-30T13:43:56Z")

</div>

Hey folks,

I am having a hell of a time upgrading my one standalone docker container. So far (up to 4.8.1) I have been using this gem:

```auto
version: '2'

services:
  rocketchat-nnx:
    image: registry.rocket.chat/rocketchat/rocket.chat:4.8.1
    command: >
      bash -c
        "for i in `seq 1 30`; do
          node main.js &&
          s=$$? && break || s=$$?;
          echo \"Tried $$i times. Waiting 5 secs...\";
          sleep 5;
        done; (exit $$s)"
    restart: unless-stopped
    volumes:
      - /var/docker_data/chat.example.com/rocketchat:/var/lib/rocket.chat
    environment:
      - PORT=3003
      - ROOT_URL=https://chat.example.com
      - MONGO_URL=mongodb://mongo-nnx:27017/rocketchat
      - MONGO_OPLOG_URL=mongodb://mongo-nnx:27017/local
      - MAIL_URL=smtp:/mail.example.com
    depends_on:
      - mongo-nnx
    ports:
      - 3003:3003

  mongo-nnx:
    image: mongo:5.0.6
    restart: unless-stopped
    volumes:
     - /var/docker_data/chat.example.com/db:/data/db
    command: mongod --oplogSize 128 --replSet rs0

```

Now with RocketChat 5.x, the compose script got rewamped quite a lot. I tried to adapt it to the best of my abilites:

```auto
volumes:
  mongo-nnx_data: { driver: local }

services:
  rocketchat-nnx:
    image: registry.rocket.chat/rocketchat/rocket.chat:${RELEASE:-latest}
    restart: on-failure
    environment:
      PORT: 3003
      ROOT_URL: https://chat.example.com
      MONGO_URL: mongodb://mongo-nnx:27017/rocketchat
      MONGO_OPLOG_URL: mongodb://mongo-nnx:27017/local
      MAIL_URL: smtp://mail.example.com
      DEPLOY_METHOD: docker
      # DEPLOY_PLATFORM: ${DEPLOY_PLATFORM}
    depends_on:
      - mongo-nnx
    expose:
      - ${PORT:-3000}
    ports:
      - "${BIND_IP:-0.0.0.0}:${HOST_PORT:-3000}:${PORT:-3000}"
    volumes:
      - /var/docker_data/chat.example.com/rocketchat:/var/lib/rocket.chat

  mongo-nnx:
    image: mongo:${MONGODB_VERSION:-4.4}
    restart: on-failure
    volumes:
      - /var/docker_data/chat.example.com/db:/data/db
    environment:
      MONGODB_REPLICA_SET_MODE: primary
      MONGODB_REPLICA_SET_NAME: ${MONGODB_REPLICA_SET_NAME:-rs0}
      MONGODB_PORT_NUMBER: ${MONGODB_PORT_NUMBER:-27017}
      MONGODB_INITIAL_PRIMARY_HOST: ${MONGODB_INITIAL_PRIMARY_HOST:-mongo-nnx}
      MONGODB_INITIAL_PRIMARY_PORT_NUMBER: ${MONGODB_INITIAL_PRIMARY_PORT_NUMBER:-27017}
      MONGODB_ADVERTISED_HOSTNAME: ${MONGODB_ADVERTISED_HOSTNAME:-mongo-nnx}
      MONGODB_ENABLE_JOURNAL: ${MONGODB_ENABLE_JOURNAL:-true}
      ALLOW_EMPTY_PASSWORD: ${ALLOW_EMPTY_PASSWORD:-yes}
    command: mongod --oplogSize 128 --replSet rs0

```

With this accomodating .env file:

```auto

# Rocket.Chat version
# see:- https://github.com/RocketChat/Rocket.Chat/releases
RELEASE=5.0.5
# MongoDB endpoint (include ?replicaSet= parameter)
MONGO_URL= "mongodb://mongo-nnx:27017/rocketchat?replicaSet=rs0"
# MongoDB endpoint to the local database
MONGO_OPLOG_URL= "mongodb://mongo-nnx:27017/local"
# IP to bind the process to
BIND_IP= "127.0.0.1"
# URL used to access your Rocket.Chat instance
ROOT_URL= "https://chat.example.com"
# Port Rocket.Chat runs on (in-container)
PORT= "3000"
# Port on the host to bind to
HOST_PORT= "3003"
DOMAIN="chat.example.com"

### MongoDB configuration
# MongoDB version/image tag
MONGODB_RELEASE="5.0.6"
MONGODB_VERSION="5.0.6"

```

Now, mongo boots up and finds its database, but RC fails to connect:

```nohighlight
rocketchat-wme-rocketchat-wme-1 | at Timeout._onTimeout (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/sdam/topology.js:312:38)
rocketchat-wme-rocketchat-wme-1 | at listOnTimeout (internal/timers.js:557:17)
rocketchat-wme-rocketchat-wme-1 | at processTimers (internal/timers.js:500:7) {
rocketchat-wme-rocketchat-wme-1 | reason: TopologyDescription {
rocketchat-wme-rocketchat-wme-1 | type: 'ReplicaSetNoPrimary',
rocketchat-wme-rocketchat-wme-1 | servers: Map(1) {
rocketchat-wme-rocketchat-wme-1 | 'localhost:27017' => ServerDescription {
rocketchat-wme-rocketchat-wme-1 | _hostAddress: HostAddress { isIPv6: false, host: 'localhost', port: 27017 },
rocketchat-wme-rocketchat-wme-1 | address: 'localhost:27017',
rocketchat-wme-rocketchat-wme-1 | type: 'Unknown',
rocketchat-wme-rocketchat-wme-1 | hosts: [],
rocketchat-wme-rocketchat-wme-1 | passives: [],
rocketchat-wme-rocketchat-wme-1 | arbiters: [],
rocketchat-wme-rocketchat-wme-1 | tags: {},
rocketchat-wme-rocketchat-wme-1 | minWireVersion: 0,
rocketchat-wme-rocketchat-wme-1 | maxWireVersion: 0,
rocketchat-wme-rocketchat-wme-1 | roundTripTime: -1,
rocketchat-wme-rocketchat-wme-1 | lastUpdateTime: 448106514,
rocketchat-wme-rocketchat-wme-1 | lastWriteDate: 0,
rocketchat-wme-rocketchat-wme-1 | error: MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017
rocketchat-wme-rocketchat-wme-1 | at connectionFailureError (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/cmap/connect.js:381:20)
rocketchat-wme-rocketchat-wme-1 | at Socket.<anonymous> (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/cmap/connect.js:301:22)
rocketchat-wme-rocketchat-wme-1 | at Object.onceWrapper (events.js:520:26)
rocketchat-wme-rocketchat-wme-1 | at Socket.emit (events.js:400:28)
rocketchat-wme-rocketchat-wme-1 | at emitErrorNT (internal/streams/destroy.js:106:8)
rocketchat-wme-rocketchat-wme-1 | at emitErrorCloseNT (internal/streams/destroy.js:74:3)
rocketchat-wme-rocketchat-wme-1 | at processTicksAndRejections (internal/process/task_queues.js:82:21)
rocketchat-wme-rocketchat-wme-1 | }
rocketchat-wme-rocketchat-wme-1 | },
rocketchat-wme-rocketchat-wme-1 | stale: false,
rocketchat-wme-rocketchat-wme-1 | compatible: true,
rocketchat-wme-rocketchat-wme-1 | heartbeatFrequencyMS: 10000,
rocketchat-wme-rocketchat-wme-1 | localThresholdMS: 15,
rocketchat-wme-rocketchat-wme-1 | setName: 'rs0',
rocketchat-wme-rocketchat-wme-1 | maxSetVersion: 1,
rocketchat-wme-rocketchat-wme-1 | maxElectionId: ObjectId {
rocketchat-wme-rocketchat-wme-1 | [Symbol(id)]: Buffer(12) [Uint8Array] [
rocketchat-wme-rocketchat-wme-1 | 127, 255, 255, 255, 0,
rocketchat-wme-rocketchat-wme-1 | 0, 0, 0, 0, 0,
rocketchat-wme-rocketchat-wme-1 | 0, 16
rocketchat-wme-rocketchat-wme-1 | ]
rocketchat-wme-rocketchat-wme-1 | },
rocketchat-wme-rocketchat-wme-1 | commonWireVersion: 13,
rocketchat-wme-rocketchat-wme-1 | logicalSessionTimeoutMinutes: undefined
rocketchat-wme-rocketchat-wme-1 | }
rocketchat-wme-rocketchat-wme-1 | }
rocketchat-wme-rocketchat-wme-1 exited with code 1

```

It tries to connect to 127.0.0.1? Why would it do that?  
I set all the urls correctly; or is it due to the repl issue?

I would use the new compose, but I do not know how to migrate from old to the new. The upgrade path is not clear (or documented).

Help please 🙂

---

<div class="post-metadata">

### Author: ![dudanogueira](https://sea1.discourse-cdn.com/flex021/user_avatar/forums.rocket.chat/dudanogueira/32/2529_2.png) [@dudanogueira](https://forums.rocket.chat/u/dudanogueira)
#### Post date: [August 30, 2022, 5:59pm UTC](https://forums.rocket.chat/t/docker-upgrade-issues/14804/2 "2022-08-30T17:59:18Z")

</div>

Hi!

We did a Rocket.Lab about this a couple weeks ago:

[![](https://us1.discourse-cdn.com/flex021/uploads/rocketchat/original/2X/9/9fc9e9bd21405e37814054c09dc12410a1aea3c1.jpeg "Rocket.Lab - Docker changes in Rocket.Chat 5.X") ](https://www.youtube.com/watch?v=8DeBQsfe2rU)

**TLDR: with the change of the node connector for mongo, you need to change some some parameters for configuring it properly.**

If you read thru the [release notes of the 5.0.0 version](https://github.com/RocketChat/Rocket.Chat/releases/tag/5.0.0), you will see an important note:

If you’re using MongoDB in a Docker container, you might need to add `directConnection=true` to `MONGO_URL` and `MONGO_OPLOG_URL` environment variables. i.e.: `MONGO_URL=mongodb://mongo/rocketchat?replicaSet=rs0&directConnection=true`

Let me know if this helps.

---

<div class="post-metadata">

### Author: ![vawaver](https://sea1.discourse-cdn.com/flex021/user_avatar/forums.rocket.chat/vawaver/32/3786_2.png) [@vawaver](https://forums.rocket.chat/u/vawaver)
#### Post date: [August 30, 2022, 6:28pm UTC](https://forums.rocket.chat/t/docker-upgrade-issues/14804/3 "2022-08-30T18:28:24Z")

</div>

> [@dudanogueira](#):
>
> directConnection=true

Can you be more specific, please?  
I am not IT Pro so I would like to know how to change my docker-compose.yml

Running in docker Rocketchat 4.8.1 + MongoDB 4.4.16  
I have these lines inside my file.

```auto
environment:
      - PORT=3000 
      - ROOT_URL=http://localhost:3000
      - MONGO_URL=mongodb://mongo:27017/rocketchat 
      - MONGO_OPLOG_URL=mongodb://mongo:27017/local
      - MAIL_URL=smtp://smtp.email

```

Can you please show me the correct code for both lines `MONGO_URL` and `MONGO_OPLOG_URL`  
Thank you very much for your reply.

---

<div class="post-metadata">

### Author: ![dudanogueira](https://sea1.discourse-cdn.com/flex021/user_avatar/forums.rocket.chat/dudanogueira/32/2529_2.png) [@dudanogueira](https://forums.rocket.chat/u/dudanogueira)
#### Post date: [August 31, 2022, 5:11pm UTC](https://forums.rocket.chat/t/docker-upgrade-issues/14804/4 "2022-08-31T17:11:46Z")

</div>

Hi!

This is about it:

```auto
environment:
      - PORT=3000 
      - ROOT_URL=http://localhost:3000
      - MONGO_URL=mongodb://mongo:27017/rocketchat?directConnection=true 
      - MONGO_OPLOG_URL=mongodb://mongo:27017/local?directConnection=true
      - MAIL_URL=smtp://smtp.email

```

Also, you can use this compose.yml as a reference:

> <https://github.com/RocketChat/Docker.Official.Image/blob/master/compose.yml>

On this case, the env var MONGODB\_ADVERTISED\_HOSTNAME is the one providing the necessary configs to avoid this connection error.

---

<div class="post-metadata">

### Author: ![vawaver](https://sea1.discourse-cdn.com/flex021/user_avatar/forums.rocket.chat/vawaver/32/3786_2.png) [@vawaver](https://forums.rocket.chat/u/vawaver)
#### Post date: [September 1, 2022, 3:25pm UTC](https://forums.rocket.chat/t/docker-upgrade-issues/14804/5 "2022-09-01T15:25:03Z")

</div>

Thank you for your reply.  
I edited docker-compose.yml as you mentioned above

```auto
      - MONGO_URL=mongodb://mongo:27017/rocketchat?directConnection=true 
      - MONGO_OPLOG_URL=mongodb://mongo:27017/local?directConnection=true

```

RocketChat 5.0.5 started in the latest version but there is another problem.  
When I switch to any Room I see the error message:  
**Something went wrong. Please reload the page or contact an administrator.**

How to fix please?  
docker Rocketchat 5.0.5 + MongoDB 4.4.16  
I had to restore from backup back to RC 4.8.1 + MongoDB 4.4.16

PS: I must use MongoDB 4.4 because my CPU is not supported by MongoDB 5.

Thank you for your answer.

 ![rocketchat_error](https://us1.discourse-cdn.com/flex021/uploads/rocketchat/original/2X/d/d263722e52cbd2e0875ad44d9f92bca37c908e31.png)

---

<div class="post-metadata">

### Author: ![dudanogueira](https://sea1.discourse-cdn.com/flex021/user_avatar/forums.rocket.chat/dudanogueira/32/2529_2.png) [@dudanogueira](https://forums.rocket.chat/u/dudanogueira)
#### Post date: [September 1, 2022, 4:06pm UTC](https://forums.rocket.chat/t/docker-upgrade-issues/14804/6 "2022-09-01T16:06:27Z")

</div>

Mongo 4.4 should be fine. Indeed Mongo 5 has some compatibility issues with some CPUs

Do you see any outstanding log in developer console?  
Have you tried a hard refresh on the browser? Sometimes this can be cause by cache.

THanks!

---

<div class="post-metadata">

### Author: ![creiss](https://sea1.discourse-cdn.com/flex021/user_avatar/forums.rocket.chat/creiss/32/3455_2.png) [@creiss](https://forums.rocket.chat/u/creiss)
#### Post date: [September 9, 2022, 11:48am UTC](https://forums.rocket.chat/t/docker-upgrade-issues/14804/7 "2022-09-09T11:48:03Z")

</div>

> [@dudanogueira](#):
>
> &directConnection=true

That solved the issue completly. Thank you very much!  
(Sorry for the delayed answer).

---

<div class="post-metadata">

### Author: ![vawaver](https://sea1.discourse-cdn.com/flex021/user_avatar/forums.rocket.chat/vawaver/32/3786_2.png) [@vawaver](https://forums.rocket.chat/u/vawaver)
#### Post date: [September 11, 2022, 9:50am UTC](https://forums.rocket.chat/t/docker-upgrade-issues/14804/8 "2022-09-11T09:50:09Z")

</div>

Just for info - Rocketchat 5.1.1 + MongoDB 4.4.16 - I can confirm that it seems to work fine.

I only added

> [@dudanogueira](#):
>
> &directConnection=true

Thank you.
