Skip to content

Rocket.Chat Fails Due to TCP Broker Port Conflict (EADDRINUSE on :::XXXXX) - FIXEDΒ #248

@fgirolami29

Description

@fgirolami29

πŸ› οΈ Rocket.Chat Fails Due to TCP Broker Port Conflict (EADDRINUSE on :::41403) β€” FIXED

❗ The Problem

After restoring a Rocket.Chat instance via mongorestore (including rocketchat_apps collection), and running it behind Docker + Traefik, the platform appeared to start fine, but the logs were filled with:

ERROR .../TRANSPORTER: Server error. Error: listen EADDRINUSE: address already in use :::41403

This caused:

  • App Engine Deno subprocesses to fail.
  • Rocket.Chat UI to partially load (but no app could be loaded).
  • Broker reconnection attempts every 5 seconds.
  • No listening process actually bound to port 41403 inside the container.

πŸ§ͺ What Was Tried (and Failed)

  • Setting sysctl net.ipv6.conf.all.disable_ipv6=1 inside the container.
  • Verifying exposed ports using ss, netstat, etc. β€” no explicit conflict.
  • Explicitly setting BROKER_TRANSPORTER and ROCKETCHAT_APPS_ENGINE_BROKER_TRANSPORTER to different loopback addresses/ports.
  • No known issue from Traefik side (proxy working perfectly).

Nothing helped.


βœ… The Actual Root Cause & Fix

Turns out the issue was that two Rocket.Chat apps were already marked as manually_enabled in the DB, and both attempted to spin up their own Moleculer broker, causing an internal port collision on ::41403.

πŸ’₯ Fix (run inside Mongo shell):

use rocketchat
db.rocketchat_apps.updateMany({}, { $set: { status: 'disabled' } })

πŸŒ€ After restarting the container, the broker booted cleanly, no more EADDRINUSE, and apps could be re-enabled one by one via the UI or DB.


🧰 Config Reference (doesn’t help alone!)

⚠️ These env vars alone didn’t solve anything unless the DB apps were disabled.

rocketchat:
  image: rocketchat/rocket.chat:latest
  environment:
    BROKER_TRANSPORTER: tcp://0.0.0.0:42000
    ROCKETCHAT_APPS_ENGINE_BROKER_TRANSPORTER: tcp://127.0.0.1:42000
  sysctls:
    - net.ipv6.conf.all.disable_ipv6=1

πŸ’‘ Suggestions

  • Rocket.Chat should check for multiple apps trying to bind the same broker port.

  • Perhaps include a startup flag like:

    DISABLE_ALL_APPS_ON_BOOT=true
    

    …to prevent these port conflicts after database restores or migrations.

  • At the very least, if EADDRINUSE is detected, auto-disable the crashing app with an informative log.


πŸ’¬ Hope this helps someone who is restoring or migrating Rocket.Chat and hitting this obscure bug.

Let me know if logs or further context are useful!


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions