Why can't I access the EC2 metadata URL on a Windows VM?

  • Page Owner: Not Set
  • Last Reviewed: 2018-08-31

When I try to access the metadata URL (http://169.254.169.254/latest/meta-data/) I always get a timeout. What might cause this?


Answer

This can happen with Windows VM when you clone an existing instance into a different availability zone. The fix is to re-initialize the instance using Amazon's InitializeInstance.ps1 script.

From Amazon's support on this topic:

  1. Please edit the 'C:\ProgramData\Amazon\EC2-Windows\Launch\Config\LaunchConfig.json' file in your instance

  2. Please set the adminPasswordType as DoNothing if you want to keep using the same administrator password.

  3. Please open powershell with 'run as administrator' and run the following command: C:\ProgramData\Amazon\EC2-Windows\Launch\Scripts\InitializeInstance.ps1 -Schedule

  4. Please reboot your instance and it will take some time to finish the initialization task.

  5. When the status check passed, please login into instance and try to access the metadata URI

Note please make sure that you have run InitializeInstance.ps1 -Schedule before you create a Windows 2016 custom AMI. Below are the steps how to create Windows 2016 custom AMI.

  1. Edit the LaunchConfig.json
  2. Run InitializeInstance.ps1 -Schedule
  3. Stop the Windows 2016 instance
  4. Create the AMI for your instance.

For more information: https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ec2launch.html#ec2launch-inittasks