From 847a6c688138c8178091318c9f214666369c65fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=20Luis=20Monta=C3=B1es?= Date: Fri, 1 May 2026 19:08:28 +0200 Subject: [PATCH] =?UTF-8?q?deploy:=20fix=20healthcheck=20=E2=80=94=20hit?= =?UTF-8?q?=20127.0.0.1=20not=20localhost?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit wget inside the alpine container resolves `localhost` to ::1, but nginx only binds IPv4 with `listen 80;`, so the healthcheck saw 'Connection refused' even though the container was happily serving traffic to Caddy. Pinning the check to 127.0.0.1 keeps it strictly IPv4. --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 2e3ef0f..da5b052 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,5 +10,6 @@ COPY nginx.conf /etc/nginx/conf.d/default.conf COPY web/ /usr/share/nginx/html/ EXPOSE 80 +# 127.0.0.1 on purpose: nginx binds IPv4 only and `localhost` may resolve to ::1 HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ - CMD wget -qO- http://localhost/ >/dev/null || exit 1 + CMD wget -qO- http://127.0.0.1/ >/dev/null || exit 1