How do I associate a static public IP address with my EC2 Windows or Linux instance?

Last updated: 2021-06-24

The auto-assigned public IP address associated with my Amazon Elastic Compute Cloud (Amazon EC2) instance changes every time I stop and start the instance. How can I assign a static public IP address to my Windows or Linux EC2 instance that doesn't change when I stop/start the instance?

Short description

An Elastic IP address is a static public IPv4 address associated with your AWS account in a specific Region. Unlike an auto-assigned public IP address, an Elastic IP address is preserved after you stop and start your instance in a virtual private cloud (VPC).

You can associate an Elastic IP address with your EC2 instance at any time using one of the following tools:

  • The Amazon EC2 console
  • The AWS Command Line Interface (AWS CLI)
  • AWS Tools for Windows PowerShell

Keep the following points in mind when working with static IP addresses:

  • If you receive errors when running AWS CLI commands, make sure that you’re using the most recent version of the AWS CLI.
  • You can't retain or reserve the current public IP address assigned to the instance using auto-assigned public IP address.
  • You can't convert an auto-assigned public IP address to an Elastic IP address.
  • There is a default limit of 5 Elastic IP addresses per Region per AWS account. For more information about limits and how to request an increase, see Elastic IP address limit.


To allocate and associate an Elastic IP address with your EC2 Windows or Linux instance, follow these steps:

  1. Allocate an Elastic IP address from either Amazon’s pool of public IPv4 addresses or a custom IP address pool that you bring to your AWS account.
  2. Associate the Elastic IP address with a running instance.

You can also disassociate an existing Elastic IP address, and then re-associate it with a different instance.

Did this article help?

Do you need billing or technical support?