From 6ddae87d3b931d6ee545246a7bb3cc0b55d6e341 Mon Sep 17 00:00:00 2001 From: Christian Heim Date: Mon, 6 Jul 2026 07:26:43 +0200 Subject: [PATCH 1/3] fix: fall back to IPv4 bind address when IPv6 is disabled Commit 84a119f switched --bind-addr to "[::]:8443" for dual-stack, but binding fails with EAFNOSUPPORT when IPv6 is disabled in the kernel, leaving code-server unreachable. Detect IPv6 via /proc/net/if_inet6 and fall back to 0.0.0.0:8443 when it is unavailable. --- root/etc/s6-overlay/s6-rc.d/svc-code-server/run | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/root/etc/s6-overlay/s6-rc.d/svc-code-server/run b/root/etc/s6-overlay/s6-rc.d/svc-code-server/run index 5e2ecba4..4e762267 100755 --- a/root/etc/s6-overlay/s6-rc.d/svc-code-server/run +++ b/root/etc/s6-overlay/s6-rc.d/svc-code-server/run @@ -18,12 +18,21 @@ if [[ -z ${PWA_APPNAME} ]]; then PWA_APPNAME="code-server" fi +# Bind to the IPv6 wildcard (dual-stack, also serves IPv4) when IPv6 is +# available, otherwise fall back to the IPv4 wildcard. Binding to "[::]" +# fails outright on hosts/containers where IPv6 is disabled. +if [[ -e /proc/net/if_inet6 ]]; then + BIND_ADDR="[::]:8443" +else + BIND_ADDR="0.0.0.0:8443" +fi + if [[ -z ${LSIO_NON_ROOT_USER} ]]; then exec \ s6-notifyoncheck -d -n 300 -w 1000 -c "nc -z 127.0.0.1 8443" \ s6-setuidgid abc \ /app/code-server/bin/code-server \ - --bind-addr "[::]:8443" \ + --bind-addr "${BIND_ADDR}" \ --user-data-dir /config/data \ --extensions-dir /config/extensions \ --disable-telemetry \ From 3ec2bdbaf3f69e07f4fbfadc6c98aa3db658480d Mon Sep 17 00:00:00 2001 From: Christian Heim Date: Mon, 6 Jul 2026 07:39:56 +0200 Subject: [PATCH 2/3] docs(changelog): note ipv4 bind fallback when ipv6 is disabled --- README.md | 1 + readme-vars.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/README.md b/README.md index 77d15e92..165ab84d 100644 --- a/README.md +++ b/README.md @@ -329,6 +329,7 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64 ## Versions +* **06.07.26:** - Fall back to ipv4 bind address when ipv6 is disabled in the kernel. * **17.05.26:** - Let server listen on both ipv4 and ipv6 even when running container as root. * **10.08.25:** - Let server listen on both ipv4 and ipv6. * **03.06.25:** - Allow setting PWA name using env var `PWA_APPNAME`. diff --git a/readme-vars.yml b/readme-vars.yml index 3e4b7aa7..b89d2e21 100644 --- a/readme-vars.yml +++ b/readme-vars.yml @@ -102,6 +102,7 @@ init_diagram: | "code-server:latest" <- Base Images # changelog changelogs: + - {date: "06.07.26:", desc: "Fall back to ipv4 bind address when ipv6 is disabled in the kernel."} - {date: "17.05.26:", desc: "Let server listen on both ipv4 and ipv6 even when running container as root."} - {date: "10.08.25:", desc: "Let server listen on both ipv4 and ipv6."} - {date: "03.06.25:", desc: "Allow setting PWA name using env var `PWA_APPNAME`."} From e917f170e886f0bc2fc03b49b2df2e7a3ae9d686 Mon Sep 17 00:00:00 2001 From: Christian Heim Date: Thu, 10 Sep 2026 08:18:25 +0200 Subject: [PATCH 3/3] Make the listen address user configurable. --- README.md | 3 +++ root/etc/s6-overlay/s6-rc.d/svc-code-server/run | 16 +++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 165ab84d..19fd7885 100644 --- a/README.md +++ b/README.md @@ -118,6 +118,7 @@ services: - PROXY_DOMAIN=code-server.my.domain #optional - DEFAULT_WORKSPACE=/config/workspace #optional - PWA_APPNAME=code-server #optional + - BIND_ADDR="[::]:8443" #optional volumes: - /path/to/code-server/config:/config ports: @@ -140,6 +141,7 @@ docker run -d \ -e PROXY_DOMAIN=code-server.my.domain `#optional` \ -e DEFAULT_WORKSPACE=/config/workspace `#optional` \ -e PWA_APPNAME=code-server `#optional` \ + -e BIND_ADDR="[::]:8443" #optional -p 8443:8443 \ -v /path/to/code-server/config:/config \ --restart unless-stopped \ @@ -163,6 +165,7 @@ Containers are configured using parameters passed at runtime (such as those abov | `-e PROXY_DOMAIN=code-server.my.domain` | If this optional variable is set, this domain will be proxied for subdomain proxying. See [Documentation](https://github.com/coder/code-server/blob/main/docs/guide.md#using-a-subdomain) | | `-e DEFAULT_WORKSPACE=/config/workspace` | If this optional variable is set, code-server will open this directory by default | | `-e PWA_APPNAME=code-server` | If this optional variable is set, the PWA app will the specified name. | +| `-e BIND_ADDR=[::]:8443` | If this optional variable is set, code-server will listen to this address instead of auto-detecting. | | `-v /config` | Contains all relevant configuration files. | | `--read-only=true` | Run container with a read-only filesystem. Please [read the docs](https://docs.linuxserver.io/misc/read-only/). | | `--user=1000:1000` | Run container with a non-root user. Please [read the docs](https://docs.linuxserver.io/misc/non-root/). | diff --git a/root/etc/s6-overlay/s6-rc.d/svc-code-server/run b/root/etc/s6-overlay/s6-rc.d/svc-code-server/run index 4e762267..a0bc5cc7 100755 --- a/root/etc/s6-overlay/s6-rc.d/svc-code-server/run +++ b/root/etc/s6-overlay/s6-rc.d/svc-code-server/run @@ -18,13 +18,15 @@ if [[ -z ${PWA_APPNAME} ]]; then PWA_APPNAME="code-server" fi -# Bind to the IPv6 wildcard (dual-stack, also serves IPv4) when IPv6 is -# available, otherwise fall back to the IPv4 wildcard. Binding to "[::]" -# fails outright on hosts/containers where IPv6 is disabled. -if [[ -e /proc/net/if_inet6 ]]; then - BIND_ADDR="[::]:8443" -else - BIND_ADDR="0.0.0.0:8443" +if [[ -z ${BIND_ADDR} ]] ; then + # Bind to the IPv6 wildcard (dual-stack, also serves IPv4) when IPv6 is + # available, otherwise fall back to the IPv4 wildcard. Binding to "[::]" + # fails outright on hosts/containers where IPv6 is disabled. + if [[ -e /proc/net/if_inet6 ]]; then + BIND_ADDR="[::]:8443" + else + BIND_ADDR="0.0.0.0:8443" + fi fi if [[ -z ${LSIO_NON_ROOT_USER} ]]; then