Skip to content

Commit 6ddae87

Browse files
committed
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.
1 parent 84a119f commit 6ddae87

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

  • root/etc/s6-overlay/s6-rc.d/svc-code-server

root/etc/s6-overlay/s6-rc.d/svc-code-server/run

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,21 @@ if [[ -z ${PWA_APPNAME} ]]; then
1818
PWA_APPNAME="code-server"
1919
fi
2020

21+
# Bind to the IPv6 wildcard (dual-stack, also serves IPv4) when IPv6 is
22+
# available, otherwise fall back to the IPv4 wildcard. Binding to "[::]"
23+
# fails outright on hosts/containers where IPv6 is disabled.
24+
if [[ -e /proc/net/if_inet6 ]]; then
25+
BIND_ADDR="[::]:8443"
26+
else
27+
BIND_ADDR="0.0.0.0:8443"
28+
fi
29+
2130
if [[ -z ${LSIO_NON_ROOT_USER} ]]; then
2231
exec \
2332
s6-notifyoncheck -d -n 300 -w 1000 -c "nc -z 127.0.0.1 8443" \
2433
s6-setuidgid abc \
2534
/app/code-server/bin/code-server \
26-
--bind-addr "[::]:8443" \
35+
--bind-addr "${BIND_ADDR}" \
2736
--user-data-dir /config/data \
2837
--extensions-dir /config/extensions \
2938
--disable-telemetry \

0 commit comments

Comments
 (0)