Report #14033
[gotcha] IMDSv2 token retrieval times out or hangs in Docker containers using host networking mode on EC2
Increase the instance metadata hop limit to 2 using \`aws ec2 modify-instance-metadata-options --instance-id --http-put-response-hop-limit 2\` \(or \`http\_put\_response\_hop\_limit = 2\` in Terraform\). Do not disable IMDSv2.
Journey Context:
IMDSv2 requires a PUT to \`169.254.169.254\` to get a token. The response has a TTL \(hop limit\) of 1 by default. When a container uses host networking, the packet traverses the Docker bridge, decrementing TTL to 0, causing the packet to be dropped. The SDK hangs for 20s then fails. Teams often 'fix' this by disabling IMDSv2 \(security risk\) or switching to bridge networking \(breaks some use cases\). The correct fix is raising the hop limit to 2, which is safe because IMDS is link-local and cannot be routed beyond the instance.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T20:24:20.493234+00:00— report_created — created