fix(docker): pin standalone bind host against runtime HOSTNAME injection#1005
Closed
jee7s wants to merge 1 commit into
Closed
fix(docker): pin standalone bind host against runtime HOSTNAME injection#1005jee7s wants to merge 1 commit into
jee7s wants to merge 1 commit into
Conversation
The v1.0.0 prod rollout crash-looped: every task exited 1 at boot with 'Failed to start server: getaddrinfo EAI_AGAIN default'. The Next standalone server listens on $HOSTNAME (next/dist/build/utils.js), and ECS Managed Instances host-network tasks set a container hostname at create time, injecting HOSTNAME=default into the runtime env over the image's ENV HOSTNAME=0.0.0.0. Fargate/awsvpc (dev) never injects, which is why only prod hit it. Pin the bind address in the CMD itself so no runtime injection can override it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
thpr
approved these changes
Jul 15, 2026
Contributor
Author
|
Superseded by infra#124 — same root cause, fixed via task-def |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
v1.0.0 prod deploy failed at Deploy to ECS (run 29422682506): every task exited 1 at boot with
Root cause
The Next standalone
server.jsbinds toprocess.env.HOSTNAME || '0.0.0.0'. The Dockerfile setsENV HOSTNAME=0.0.0.0, but ECS Managed Instances host-network tasks set a container hostname at create time, which injectsHOSTNAME=defaultinto the runtime env over the image ENV. The server then tries to bind to a host literally nameddefault→ DNS failure → exit 1 → crash loop →services-stablewaiter timeout.Dev never hit this: Fargate/awsvpc doesn't support container hostnames, so nothing overrides the image ENV.
Fix
Pin the bind address in the CMD itself —
sh -c "HOSTNAME=0.0.0.0 exec node …"— so no runtime injection can override it.execkeeps node as PID 1 for signal handling. The migrate task overrides the command entirely and is unaffected.Verified:
env HOSTNAME=default sh -c 'HOSTNAME=0.0.0.0 exec node -p "process.env.HOSTNAME"'→0.0.0.0; CI's deploy-build smoke test boots the image with the new CMD.After merge: delete + re-cut the v1.0.0 release (third time — migrations already applied and are idempotent).
🤖 Generated with Claude Code