From 3a73870706e0f4e039d2d79da31bcdbb4e3dfcdd Mon Sep 17 00:00:00 2001 From: UNITRONIX <36471318+UNITRONIX@users.noreply.github.com> Date: Mon, 6 Apr 2026 17:03:11 +0200 Subject: [PATCH] Fix port 21121 connection refused in Docker (API_HOST binding) Root cause: config.js defaults apiHost to 127.0.0.1 (localhost-only). Inside Docker containers, this means port 21121 only listens on the loopback interface, making it unreachable from outside the container despite docker port mapping. docker-compose.single.yml already had API_HOST=0.0.0.0, but docker-compose.yml (multi-container) and docker-compose.quick.yml (GHCR pre-built) were missing it. Fixes: - docker-compose.yml: Add HOST=0.0.0.0 and API_HOST=0.0.0.0 - docker-compose.quick.yml: Add HOST=0.0.0.0 and API_HOST=0.0.0.0 - Dockerfile.console: Add ENV API_HOST=0.0.0.0 - Dockerfile (single): Add ENV API_HOST=0.0.0.0 - docker/entrypoint.sh: Export API_HOST and HOST defaults - docker/supervisord.conf: Add API_HOST and HOST to console env Fixes #78 --- Dockerfile | 1 + Dockerfile.console | 1 + docker-compose.quick.yml | 2 ++ docker-compose.yml | 2 ++ docker/entrypoint.sh | 4 ++++ docker/supervisord.conf | 2 ++ 6 files changed, 12 insertions(+) diff --git a/Dockerfile b/Dockerfile index 9e216077..231905af 100644 --- a/Dockerfile +++ b/Dockerfile @@ -100,6 +100,7 @@ ENV NODE_ENV=production ENV PORT=5000 ENV SIGNAL_PORT=21116 ENV HOST=0.0.0.0 +ENV API_HOST=0.0.0.0 ENV DATA_DIR=/app/data ENV RUSTDESK_PATH=/opt/rustdesk ENV DB_PATH=/opt/rustdesk/db_v2.sqlite3 diff --git a/Dockerfile.console b/Dockerfile.console index 1fbd8b2c..9507dce2 100644 --- a/Dockerfile.console +++ b/Dockerfile.console @@ -56,6 +56,7 @@ RUN mkdir -p /app/data /opt/rustdesk && \ ENV NODE_ENV=production ENV PORT=5000 ENV HOST=0.0.0.0 +ENV API_HOST=0.0.0.0 ENV DATA_DIR=/app/data ENV RUSTDESK_PATH=/opt/rustdesk ENV DB_PATH=/app/data/db_v2.sqlite3 diff --git a/docker-compose.quick.yml b/docker-compose.quick.yml index 937966a9..d60fcd4e 100644 --- a/docker-compose.quick.yml +++ b/docker-compose.quick.yml @@ -60,6 +60,8 @@ services: environment: - NODE_ENV=production - PORT=5000 + - HOST=0.0.0.0 + - API_HOST=0.0.0.0 - SERVER_BACKEND=betterdesk - BETTERDESK_API_URL=http://betterdesk-server:21114/api - RUSTDESK_PATH=/opt/rustdesk diff --git a/docker-compose.yml b/docker-compose.yml index c952e2f1..388aa0b9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -66,6 +66,8 @@ services: environment: - NODE_ENV=production - PORT=5000 + - HOST=0.0.0.0 + - API_HOST=0.0.0.0 - SERVER_BACKEND=betterdesk - HBBS_API_URL=http://betterdesk-server:21114/api - BETTERDESK_API_URL=http://betterdesk-server:21114/api diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index e8452e9b..9e42bdde 100644 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -79,6 +79,10 @@ fi # Ensure Go server uses correct signal port (not NODE.js PORT) export SIGNAL_PORT="${SIGNAL_PORT:-21116}" +# Ensure Node.js Client API binds to all interfaces (not just localhost) +export API_HOST="${API_HOST:-0.0.0.0}" +export HOST="${HOST:-0.0.0.0}" + # Relay server address: if not explicitly set, try to auto-detect public IP. # Inside Docker, the Go server's own detection may return the container's # internal IP (172.x.x.x) which is unreachable by remote clients. diff --git a/docker/supervisord.conf b/docker/supervisord.conf index f8ce3190..c0a2378b 100644 --- a/docker/supervisord.conf +++ b/docker/supervisord.conf @@ -56,4 +56,6 @@ stdout_logfile=/dev/stdout stdout_logfile_maxbytes=0 stderr_logfile=/dev/stderr stderr_logfile_maxbytes=0 +; Ensure Client API binds to all interfaces inside container +environment=API_HOST="0.0.0.0",HOST="0.0.0.0" priority=200