-
Notifications
You must be signed in to change notification settings - Fork 235
Description
๐ ๏ธ 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=1inside the container. - Verifying exposed ports using
ss,netstat, etc. โ no explicit conflict. - Explicitly setting
BROKER_TRANSPORTERandROCKETCHAT_APPS_ENGINE_BROKER_TRANSPORTERto 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
EADDRINUSEis 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!