amazon-web-servicesamazon-ec2metadata

AWS: Problem accessing metadata tags from within EC2


curl -v http://169.254.169.254/latest/meta-data/
*   Trying 169.254.169.254:80...
* TCP_NODELAY set
* connect to 169.254.169.254 port 80 failed: Timed out
* Failed to connect to 169.254.169.254 port 80: Timed out
* Closing connection 0
curl: (28) Failed to connect to 169.254.169.254 port 80: Timed out

O.S : Windows 10.

Access to all other websites work but not this IP that has metadata about the instance.


Solution

  • I had the same issue recently. In my case, there was no route to 169.254.169.254 present in my route table.

    Therefore I would first do a route print from the command line and confirm whether or not any routes present to the destination 169.254.169.254.

    In my case, the solution was to simply restart the Ec2Config windows service to get the route added.

    Hope this helps.

    Reference: https://aws.amazon.com/premiumsupport/knowledge-center/waiting-for-metadata/

    2024 Update:

    For anyone that finds this issue in 2024:

    I was facing the same issue but as per Amazon Docs:

    The latest launch agent for Windows Server 2022 and later operating system versions is EC2Launch v2, which replaces both EC2Config and EC2Launch, and comes pre-installed on AWS Windows Server 2022 and 2025 AMIs.

    So what I did was just start Amazon EC2Launch Service in Windows Services (in my case it wasn't running) and the missing routes were added, I was then able to curl the metadata service IP (169.254.169.254) successfully.