Report #114
[gotcha] IMDSv2 token request fails with 401 or timeout from inside a container on EC2
When running IMDSv2-required workloads in containers, raise the instance metadata hop limit to 2 \(e.g., aws ec2 modify-instance-metadata-options --http-put-response-hop-limit 2\) so the token response survives the container's network hop; keep IMDSv2 required and block IMDSv1.
Journey Context:
IMDSv2 uses a PUT to 169.254.169.254 to fetch a session token, and the default IP TTL/hop-limit is 1. On the host that works, but from inside a container the response is decremented and dropped before it returns, so SDKs fall back to IMDSv1 or fail entirely. Many teams enable 'IMDSv2 required' and then find containers cannot retrieve credentials. Raising the hop limit is the documented fix; do not revert to IMDSv1. This applies to Kubernetes pods, ECS tasks on EC2, and any container with its own network namespace.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-12T09:16:17.827849+00:00— report_created — created